How can I process keyboard input to my program, and still have the focus shifted to another windows form?
I'm trying to shift focus from one windows form to another and then take a screenshot of it, however, the focus is returned to the original form when I try to enter a command, mouse or otherwise, to let the program know that I want to take the screenshot.
The problem occurs in trying to take screen shots of "Active Windows".
AlanPosted Nov 22, 2007, 7:14 PM
Assuming you have the handle (hWnd) to the other window, then you can force focus onto it using the SetForegroundWindow() API function, whose P/Invoke signature is:
[DllImport("user32.dll")]
static extern int SetForegroundWindow(IntPtr hWnd);
You could then send keystrokes to the other window using the SendKeys class:
http://msdn2.microsoft.com/EN-US/library/system.windows.forms.sendkeys.aspx