views:

118

answers:

1

Is there a way to be notified when the content of the clipboard changes? I looked a class "Clipboard". It has numerous methods to set the clipboard content but no event.

+2  A: 

There's nothing in the Framework, I believe. You can do it with Win32, though. Look into SetClipboardViewer in User32.dll:

[DllImport("User32.dll", CharSet=CharSet.Auto)]
public static extern IntPtr SetClipboardViewer(IntPtr hWndNewViewer);

It gets a little involved. It isn't a straightforward notification, but a message chain; you'll need to pass the notification on to the next receiver.

This article has a good description of the steps necessary.

Michael Petrotta