Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hook a global PASTE EVENT? [closed]

Tags:

c#

events

hook

I am developing a software that needs to know when the PASTE EVENT (through the context menu or ctrl+V) happens (only for files / directories). More or less, something like it happens with TeraCopy or Copy Handler. When you copy and then paste, it is TeraCopy that handles the pastings.
I know more or less how to capture the COPY EVENT, you only have to set a ClipboardViewer and you catch all global COPY EVENTS (in fact is called: WM_DRAWCLIPBOARD). You can learn this here: http://www.radsoftware.com.au/articles/clipboardmonitor.aspx But the ClipBoardViewer does not provide you with the ability to catch the PASTE EVENT.

like image 337
netadictos Avatar asked Nov 14 '22 16:11

netadictos


1 Answers

The process of state change via "Pasting" is specific to individual applications, as such there is no magic way to discover whether the state of an application changed after accessing the clipboard.

The best you can do is detect whether an application has retrieved data from the clipboard. Again, there's no way of knowing what the application did with this data. It's akin to knowing someone opened their frontdoor without knowing where they went, if anywhere.

If you do want to try this you could do something like hooking the GetClipboardData function. For information about how to palce system-wide API hooks check out the samples in Micrsoft Detours - http://research.microsoft.com/sn/detours

like image 195
Andrew Grant Avatar answered Dec 10 '22 11:12

Andrew Grant