tags:

views:

29

answers:

1

I'm trying to build a script that will add the currently selected text to the end of a file. So far it looks like cat selected_text >> quotes.txt.

Is there any way, either in command line or in C/C++ to get the currently selected text from the currently active window?

+1  A: 

Take a look at the xclip command

This command operates on X11 selections (the middle-click paste clipboard). It can be used to retrieve the last block of text that was selected using the mouse.

Alexandre Jasmin
Download from http://sourceforge.net/projects/xclip/
chrisaycock