Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to find where the Clipboard data copied in C#


Hi Team,

Forgive me if this is invalid question. I'm not sure about this.

Is there any ways to find the where the clipboard text copied?


What I have tried:

For example,

In C# we can retrieve the clipboard text using <pre> var clipboardObj = (DataObject)Clipboard.GetDataObject()


Here can we get where the data copied? like Excel or MSAccess or Notepad or something?

Thanks in advance.

Regards,
Arunkumar Murugesan
Posted
Updated 13-May-20 1:56am
Comments
F-ES Sitecore 13-May-20 8:28am    
Not really, if you look at "((DataObject)Clipboard.GetDataObject()).GetFormats()" then it will show the formats of data in the clipboard, so Excel will have CSV, Word will have Rich Text etc, but other apps can put that type of data in the clipboard too so it is by no means definitive.
Arunkumar Murugesan 14-May-20 0:28am    
Thanks F-ES Sitecore..

1 solution

The clipboard is just a repository for data and does not have a link back to the source. Consider the situation where you copy some text from a Word document then immediately close Word, and delete the document. The data is still in the clipboard but there is no way to trace where it came from.
 
Share this answer
 
Comments
Arunkumar Murugesan 13-May-20 8:05am    
Thanks Richard. I understand. But it would be very helpful for me if there is a way to find the data copied from.
Richard MacCutchan 13-May-20 8:20am    
Yes, but there isn't.
Maciej Los 13-May-20 8:25am    
Agree. Take a look at MSDN documentation: Clipboard Class (System.Windows) | Microsoft Docs[^]
This class has no property, member or method which will return such of information.
Maciej Los 13-May-20 8:22am    
5ed!
Richard MacCutchan 13-May-20 8:28am    
Thanks Maciej. But I think the other comment was for the OP.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900