in reply to Win32::Clipboard from within a wxPerl

If you are running a threaded perl, then this is one way. (I know nothing of wxPerl so my apologies if it doesn't work there). This uses the 5.8 flavour of threads, but it wouldn't take much work to get it going with a 5.6 threaded perl I think.

#! perl -slw use strict; require 5.008; use threads; use threads::shared; use Thread::Queue; use Win32::Clipboard; $|++; # Disable buffering so we see the changes immediatly my $flag : shared = 0; # A flag to tell the thread when to die my $q = new Thread::Queue; # Create a thread sub watchClipboard{ my $clip = Win32::Clipboard(); # Get a handle to the CB while ( !$flag ) { # Repeat until we're told to die $clip->WaitForChange(); # Block waiting for an event # Once something happens, queue it back to the main program $q->enqueue( $clip->Get() ); } }; my $watcher = threads->create( 'watchClipboard' ); my $i =0; # A count to allow the demo to self terminate while( $i < 600 ) { # Wait for 1 minute of inactivity before calling i +t quits. while( $q->pending ) { # If the watcher put anything in the queue, display it. $i = 0; print( $/, 'From the clipboard: ', $q->dequeue ); } # Show we can be doing other things printf "\rMeanwhile, just killing time: %2.1f", $i++/10; # Stop the demo from chewing cpu. select undef,undef,undef, .1; } $flag = 1; # Set the flag asking the thread to +die Win32::Clipboard()->Set(''); # Put something on the CB to break th +e wait $watcher->join; # Wait for it to die. exit;

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller