I am using System.Windows.Clipboard
to copy some text, and I would like to know is there a chance to get the origin source,
e.g. a the file where I copyied it from, or the website, folder.... ?
Thanks
I am using System.Windows.Clipboard
to copy some text, and I would like to know is there a chance to get the origin source,
e.g. a the file where I copyied it from, or the website, folder.... ?
Thanks
GetClipboardOwner() can be used to get the Handle of the Window that last placed data into the Clipboard.
The returned handle is then passed to GetWindowThreadProcessId() to get the Process ID and Thread ID of that Window.
The Process ID is the parameter to pass to the .Net
System.Diagnostics.Process.GetProcessById()
method to retrieve the information needed.Windows API declarations. The overloaded
GetClipboardOwnerProcessID()
wrapper method returns the ProcessID of the ClipBoard Owner and, optionally, its Thread ID.The wrapper can be called like this, if you just need the Process Id:
Or this way, if you also need the Thread Id:
Pass the returned value to the
Process.GetProcessById()
method:If you copy some text from your browser, the
ProcessName
will be the name of your browser and theProcessFileName
the path to its executable.