Forum: Ruby how to copy data to clipboard

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Li C. (Guest)
on 2008-10-10 17:31
Hi all,

I want to send the  word "copy" to the clipboard  and trigger an event
like ctrl-c. which gem/library is used for this purpose?

Thanks,

Li
Alex F. (Guest)
on 2008-10-10 17:55
(Received via mailing list)
Li Chen wrote:
> Hi all,
>
> I want to send the  word "copy" to the clipboard  and trigger an event
> like ctrl-c. which gem/library is used for this purpose?

It depends what platform you're using.

For Win32 only, I'd expect you could use Win32API to do this, though
I've no idea what API call you'd need.

For OS X only, I'd look into Ruby-Cocoa or MacRuby. Again, I don't know
the specific API call needed.

For Linux/GTK only, try GTK-Ruby. Although GTK is meant to be somewhat
cross-platform, I remember reading somewhere that clipboard functions
don't work on Windows. This bug may be fixed now, however.

For a cross-platform solution, try one of the cross-platform toolkits,
either QT, FxRuby or wxRuby. With wxRuby, you would use the
Wx::Clipboard and Wx::TextDataObject classes.

a
This topic is locked and can not be replied to.