Allison, Jason (JALLISON) wrote:

> Are you saying your code below doesn't work?  It seems to work for me.
> What was I doing wrong?

No, my code works.  The change notify doesn't seem to work in the
clipboard module amongst other things.  Your code may have had a
bug or two also - don't really remember what worked and what didn't.

> From: $Bill Luebkert [mailto:[EMAIL PROTECTED] 
> Sent: Friday, December 03, 2004 8:10 PM
> To: Allison, Jason (JALLISON)
> Cc: [EMAIL PROTECTED]
> Subject: Re: Win32::ClipBoard WaitForChange with LWP::UserAgent->new()
> 
> 
> Allison, Jason (JALLISON) wrote:
> 
> 
>>Hello all,
>>
>>-- This is perl, v5.8.4 built for MSWin32-x86-multi-thread -- Win2k 
>>Professional
>>
>>Im trying to shortcut an intranet web lookup using the 
>>Win32::ClipBoard module.  The unusualness of this not working is the 
>>first iteration into the loop/WaitForChange works, but it doesn't work
> 
> 
>>for susequent changes, which makes no sense.  My original thoughts 
>>were along the lines of improperly scoped LWP of HTTP variables, but I
> 
> 
>>just don't see it.  In addition, I use this code w/in a module using 
>>Tk as a front-end and it works fine (sans Win32::Clipboard).
>>
>>Below is made my best basic bug statement.  The code below obviosly 
>>has no valid use except to show my point.  The code below when run 
>>will determine when there is a change to the Win32 ClipBoard and paste
> 
> 
>>the google content into the clipboard and then wait for another 
>>change. When run, the code will recognize the first change to the 
>>ClipBoard, but not subsequent.
>>
>>Let me also add that the second code snippet takes out the LWP/HTTP 
>>all together and it works, however, I see some obscure "race 
>>condition" sitautions if I don't put the sleep in there.  For example,
> 
> 
>>the app will work, but I will get 2 or 3 "change"'s per copy into a 
>>clipboard
>>
>>Any ideas?
> 
> 
> It appears to be really screwed up.  Polling should work :
> 
> use strict;
> 
> use LWP;
> use HTML::Parse;
> use Win32::Clipboard;
> 
> my $prev = 'cross-reference';
> my $clip = Win32::Clipboard ($prev) or die "new clipboard: $! ($^E)";
> 
> while (1) {
>       sleep 5;
>       my $is = $clip->GetText();
>       next if $is eq $prev;
>       print "clipboard change\n";
>       print "is='$is'\n";
>       set_clipboard ();
> }
> 
> sub set_clipboard {
> 
> my $ua = LWP::UserAgent->new();
> my $url = "http://www.google.com";;
> my $req = new HTTP::Request GET => $url;
> my $response = $ua->request($req);
> my $html = $response->content;
> $clip->Set($html);
> $prev = $html;
> 
> }
> 
> __END__
> 
> 


-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to