Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Copy and Paste?

by zentara (Cardinal)
on Jun 11, 2008 at 17:54 UTC ( [id://691518]=note: print w/replies, xml ) Need Help??


in reply to Copy and Paste?

Here are a couple of ideas.

This one will let you put something into the Paste selection menu of many apps, but you need X windows running.

#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Clipboard; my $mw = tkinit; $mw->withdraw; #use Tk without showing a window my $content = 'foobar'.time; print "$content\n"; $mw->clipboardClear; $mw->clipboardAppend($content); MainLoop;

or this one will let you copy into the mouse paste buffer. Unfortunately, you need to keep the Tk program going untill you make the mouse Paste. The programs' Paste buffer gets cleared when Tk exits.

#!/usr/bin/perl use warnings; use strict; use Tk; # a "phantom newline"-free copy'n'paste to # the mouse clipboard my $mw = tkinit; my $textbox = $mw->Text(); #never packed $mw->Button(-text =>'CLipAppend', -command=>sub{ $textbox->clipboardClear; $textbox->delete('1.0','end'); $textbox->insert('end','foobarz'); $textbox->selectAll; #this next line must come after the selectAll $textbox->delete('end - 1 chars','end'); $textbox->clipboardColumnCopy; print chr(07); #beep })->pack(); MainLoop;

Perl Gtk2 has some similar things, google for "Gtk2::Clipboard"


I'm not really a human, but I play one on earth CandyGram for Mongo

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://691518]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2025-06-17 16:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.