简体   繁体   中英

How to override copy-paste functionality in Windows/Linux?

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)?

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:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM