Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
#!perl # copyright (c) Chady Kassouf 2004 # This program is free software, it is distributed under # the sames terms as Perl itself. use strict; use threads; use threads::shared; use Win32::Clipboard; use Win32::GUI; my @board : shared; push @board, '--empty--' for 0 .. 4; my @boxes; my $CLIP = Win32::Clipboard(); my $thread = threads->create("monitor"); my $main = Win32::GUI::Window->new( -name => 'main', -text => 'Win32 Multiple Clipboard', -width => 200, -height => 150 ); my $icon = Win32::GUI::Icon->new('Note.ico'); my $tray = $main->AddNotifyIcon( -name => 'tray', -icon => $icon, -tip => 'Win32 Multiple Clipboard' ); foreach (0 .. 4) { my $label = $board[$_]; $label =~ s/^(.{10})(.*)$/$1... /; $boxes[$_] = $main->AddRadioButton( -name => "board$_", -text => $label, -pos => [ 10, 10 + 20 * $_ ], ); $boxes[$_]->{-width} = 150; } $main->Show(); set_clip(1); Win32::GUI::Dialog(); ## sub set_clip { my $which = shift; $boxes[$_]->Checked(0) for 0..4; $boxes[$_]->{-text} = $board[$_] for 0..4; if ($which) { $which--; my $d = $board[$which]; $CLIP->Set($d); $main->Disable(); $main->Hide(); } } # there must be a better way for this. sub board0_Click {set_clip(1);1;} sub board1_Click {set_clip(2);1;} sub board2_Click {set_clip(3);1;} sub board3_Click {set_clip(4);1;} sub board4_Click {set_clip(5);1;} sub tray_Click { # move the window near the task bar my $desk = Win32::GUI::GetDesktopWindow(); my $dw = Win32::GUI::Width($desk); my $dh = Win32::GUI::Height($desk); my $x = $dw - $main->Width(); # the taskbar is 27 pixels on Xp (no Luna) my $y = $dh - $main->Height() - 27; $main->Move($x, $y); $main->Enable(); $main->Show(); set_clip(0); 1; } # this runs in another thread because it blo sub monitor { { print "[MONITOR]: Waiting for clipboard.\n"; $CLIP->WaitForChange(); print "[MONITOR]: Clipboard changed.\n"; my $data = $CLIP->Get(); last if $data eq '___EXIT___'; # skip empty and same requests redo if ($data eq $board[0] || $data eq '--empty--'); unshift @board, $data; # splice @board, 5; delete $board[$_] for 5 .. $#board + 1; redo; } } sub main_Minimize { $main->Disable(); $main->Hide(); 1; } sub main_Terminate { $CLIP->Set('___EXIT___'); $thread->join(); $CLIP->Set($board[0]); # make sure we can start next time. -1; }

In reply to Win32 Multiple Clipboards by Chady

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-19 02:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found