For a small utility I am writing (.NET, C#), I want to monitor clipboard copy operations and clipboard paste operations.
My idea is to provide my own data when pasting into an arbitrary application.
The monitoring of a copy operation can be easily done by using a clipboard viewer.
Something that seems much more advanced to me is to write a "clipboard paste provider":
I found this posting and this posting, but none of them seems to really help me.
What I guess is that I somehow have to mimic/hijack the current clipboard.
Question:
Is it possible to "wrap" the clipboard in terms of paste operations and provide my own kind of "clipboard proxy"?
Open the messaging app on your Android, and press the + symbol to the left of the text field. Select the keyboard icon. When the keyboard appears, select the > symbol at the top. Here, you can tap the clipboard icon to open the Android clipboard.
Look for a clipboard icon in the top toolbar. This will open the clipboard, and you'll see the recently copied item at the front of the list. Simply tap any of the options in the clipboard to paste it into the text field. Android does not save items to the clipboard forever.
How to turn off pasted from your Clipboard popups. Open the Settings app and tap on Privacy. Then tap on Advanced. Now scroll down until you get to Show clipboard access and then toggle it Off by tapping on it.
Look into "delayed rendering" in the WinAPI. With this technique, you load the clipboard with null handles, and upon pasting, windows notifies you with a WM_RENDERFORMAT message. This is how apps like Excel can get away with "copying" 25 different formats. It doesn't really copy them all. It'll actually produce some common ones like TEXT, but "advertises" the others like Bitmap, Html, WKS, etc., opting to wait to see what the target application wants to paste.
Consider this: you can select 5000 cells in Excel and copy, and the clipboard is updated pretty quickly. Now paste into Windows Paint, and suddenly your system crawls as Excel tries to render a huge bitmap. Older versions would usually crash, after using all available memory and eating the pagefile. This was back in the Windows 3.1 days though. Modern versions give a message about "bitmap too large" or "not enough memory".
Warning: Delayed Rendering will be prematurely triggered by apps that monitor the clipboard and auto-paste data into themselves, such as Remote Desktop, VMWare, Office Clipboard, and my own ClipMate. Some clipboard monitoring programs can be told to ignore the clipboard update by using the CF_Clipboard_Viewer_Ignore flag, which I've documented here:
link text
You need to hook in the clipboard hook by using a windows hook. A windows hook is a way of intercepting global events happening and providing your own hook procedure to replace or intercept the message. Have a look here on CodeProject that explains how to hook. Here's a clipboard helper that listens for the copy/paste functionality. Here's a Clipboard spy that just does that. Here's another article that implements a Clipboard hook.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With