1

I want to be able to paste clipboard contents with functional hyperlinks to my Winform controls. In order for this to work I tried to check if the Clipboard contains HTML and no RTF and then I could parse the HTML content accordingly. Unfortunately the Internet Explorer generates RTF and HTML in the clipboard content and that way I can't really tell that the content is comming from a browser. Microsoft word for example does the same thing and the only way I found so far to differenciate office products from IE is to check for the namespace xmlns:o"urn:schemas-microsoft-com:office:office" in the HTML content of the clipboard. I can't simply use HTML in all cases, because I prefer the RTF or simply the unicode content from other sources than browsers.

Is there a way to determine that the clipboard content comes from a specific application? In my case from IE? So far I only used Clipboard.Contains(TextDataFormat.HTML) and Clipboard.GetDataObject().GetFormats() but I can't find anything else.

  • What if the clipboard comes from an IE-powered program? Or some program that choose to generate some other HTML content that you could not understand? Better describe the error to the user. – Sheng Jiang 蒋晟 Dec 03 '13 at 23:25
  • Note that checking for content within the data (i.e. the schema of the XML) effectively triggers a "paste" operation, and will have unintended consequences, such as triggering delayed rendering, and causing network traffic if the copy/paste is done over the network with RemDesk or whatever. Things to keep in mind. – Chris Thornton Dec 13 '13 at 04:13

1 Answers1

0

You can use P/Invoke class to get the calling applications window title using http://pinvoke.net/default.aspx/user32/GetWindowText.html. For IE the title is the name of the page and suffixed with - Microsoft Internet Explorer, default title for this IE.

This is sample code how to use GetWindowsText C# how to use WM_GETTEXT / GetWindowText API

Community
  • 1
  • 1
Markus
  • 420
  • 3
  • 7