Find the answer to your Linux question:
Results 1 to 3 of 3
Hi all, is it possible to read directly the content of Clipboard without to be obliged to paste its content somewhere? I only need it's text content, which can be ...
  1. #1
    Just Joined!
    Join Date
    Oct 2004
    Posts
    62

    clipboard reading

    Hi all,
    is it possible to read directly the content of Clipboard without to be obliged to
    paste its content somewhere?
    I only need it's text content, which can be read easily from memory (if you
    know the starting address).
    If the Clipboard is saved in a temporary file it is even easier...
    Bye.

  2. #2
    Linux Newbie
    Join Date
    Jul 2008
    Posts
    181
    Yes, it's possible. In java, you could do the following, for example:

    Code:
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    String contents = (String) clipboard.getContents(null).getTransferData(DataFlavor.stringFlavor);
    The example assumes you have text in your clipboard, but that is not required.

  3. #3
    Just Joined!
    Join Date
    Oct 2004
    Posts
    62
    Hi burschik,
    thank you for replying... but i 'll never use Java or C++ (I hate OOP).
    Luckily in the meantime I found a solution using
    xclip
    I loaded it from Synaptic (I have Debian).
    For those interested i give some examples:
    Writing and reading clipboard:
    cat TxtFile | xclip -i | xclip -o > FileOut
    (which is almost the same as cat TxtFike > FileOut, but demonstrate
    that you can read & write the Clipboard)
    More interesting.... application to Google Translate:
    filtering clipboard with bash
    translate a word or a phrase w/ Google Translate + CtrlA (Select All) + CtrlC (Copy)
    then... from the shell --> xclip -o | head -n 12 | tail -n 2
    Wanting for example translate from Italian to english some chemical compounds, you obtain:
    acetilcolina --> acetylcholine
    cloruro di litio --> lithium chloride
    Bye.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...