Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Copy and Paste?

by zentara (Archbishop)
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?

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-07-25 15:14 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.