Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there a way you can send a Paste or SendKeys to a control on an external window, if you know the Handel by using Spy++?

Or even set focus to that window and then to the control? Then SendKeys
Posted

1 solution

Yep, of course this is possible.
you can achive this by using P/Invoke technologi in .NET environment.

So basically you must retreive a window handle (HWND) by it text (caption) and
mark this window as foreground with help of (WIN32 API):
C#
[DllImport("user32")]
private static extern bool SetForegroundWindow(IntPtr hwnd);


C#
[DllImport("user32.dll")]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);


and then you might just send data like
C#
SendKeys.SendWait("{TAB}");
SendKeys.SendWait("{TAB}");
SendKeys.SendWait("{ENTER}");



Or even more with help of
SendMessage(_hWnd, 0x100, (int) VKeys.VK_2, (int) VKeys.VK_2);


you can achive better result
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900