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

In reply to Re: Win32::Clipboard from within a wxPerl by BrowserUk
in thread Win32::Clipboard from within a wxPerl by Chady

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.