Click here to Skip to main content
12,399,799 members (50,489 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB VB.NET
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 28-Dec-12 4:50am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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):
[DllImport("user32")]
private static extern bool SetForegroundWindow(IntPtr hwnd);

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

and then you might just send data like
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
  Permalink  
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100