GreenEyedAndy
GreenEyedAndy

Reputation: 1525

Just 'peek' at the clipboard

Is there a way to get data from the clipboard but not remove it, so another method or application can get it?

I have a third party component where I can override the paste method, but I can not change what base.Paste() is doing. So I will try to save the clipboard data before I call base.Paste() and after that do some operation with the data.

Upvotes: 0

Views: 230

Answers (1)

Marc Wittmann
Marc Wittmann

Reputation: 2362

Just use the standard .Net Implementation.. why do you want to use a third party assembly?

  mystring = Clipboard.GetText(System.Windows.Forms.TextDataFormat.Text)

  myObject = Clipboard.GetData(format);

won`t remove the Text in the clipboard.

You can also get the Clipboard Content and Copy it back to the clipboard after your third party component removed if:

        data = Clipboard.GetData(format);
        //run 3rd party function
        Clipboard.SetData(format, data);

Upvotes: 5

Related Questions