0
SendKeys.Send("^c"); //does not work.
SendKeys.Send("^{BREAK}"); //Also does not work.
SetClipboardData(13 or 7, hWnd); //Also does not work.
SendMessage(GetForegroundWindow(), WM_COPY, IntPtr.Zero, IntPtr.Zero); (const int WM_COPY = 0x0300;)
SendCtrlC(GetForegroundWindow()); //from http://stackoverflow.com/a/273163/1386831 fails

all those fail..

What is the alternative to making a call to Clipboard.GetData() when what you're trying to copy is outside of the current application?

yumyum
  • 7
  • 6

1 Answers1

2

Find the window handle of the target control and post a WM_COPY message to it.

  • you have an example? i've attempted this multiple times. that all caps COPYDATA or whatever struct and the call, I couldn't get it working, PLEASSSSE get me a working sample... kudos :) – yumyum Feb 10 '13 at 06:52
  • Not WM_COPYDATA, just plain WM_COPY - takes no arguments: http://msdn.microsoft.com/en-us/library/windows/desktop/ms649022(v=vs.85).aspx. Sorry - don't have an example handy. – 500 - Internal Server Error Feb 10 '13 at 07:06
  • didn't work. const int WM_COPY = 0x0300 SendMessage(nextClipboardAppWindow, WM_COPY, IntPtr.Zero, IntPtr.Zero); – yumyum Feb 10 '13 at 08:10
  • or SendMessage(GetForegroundWindow(), WM_COPY, IntPtr.Zero, IntPtr.Zero); didn't work also – yumyum Feb 10 '13 at 08:23