1

I want to override the copy-paste functionality in either Windows/Linux. How can I do that?

Most applications support simple copy-paste functionality, where the text copied is the one that is currently selected. I want to modify this functionality. Instead of just copying the text, I want to also copy to clipboard: the name of the process/application from where the text was copied, datetime of the copy-paste and user of the system.

For example, when a user selects a text (say "Hello World") from a browser and pastes it into say notepad, the pasted text should be something like "Hello World" (author: , source: chrome.exe, datetime: ....)

How can I do this (either in Windows or Linux)?

Ankit
  • 6,772
  • 11
  • 48
  • 84
  • For Linux, you can look at the sources of Klipper. – Aaron Digulla May 22 '14 at 08:11
  • I would not change the standard (I guess when you do that you will run in lots of logical unpleasant situations), but add a new version which can be reached via a special key combo. Typical window managers like Gnome or KDE you can configure to run a specified program when a special key combo is pressed, and that special command could extend the current selection by the information you want. Time is easy of course, but I'm not sure where to get the information about the selection's origin from. – Alfe May 22 '14 at 08:30

1 Answers1

0

It's been a while since I looked at the clipboard but basically, you just create list to clipboard change events which the OS will send to all interested applications.

When the clipboard changes, look at the current content. When it's text (it can also be HTML or application specific binary data), then get the current content, append the information you want and set the new clipboard content.

If you use Java, you can use Toolkit.getDefaultToolkit().getSystemClipboard(); to get access to the clipboard and then add listeners for the various events.

Related:

Community
  • 1
  • 1
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820