Woody
Member
- Joined
- Apr 8, 2005
- Messages
- 7
- Programming Experience
- Beginner
Hello everyone,
I am hoping someone may be able to assist me with this issue. I have an application which launches another and has to send keystrokes etc to the external application.
I am having trouble gathering the child window information.
Here's where I am so far.
I am hoping someone may be able to assist me with this issue. I have an application which launches another and has to send keystrokes etc to the external application.
I am having trouble gathering the child window information.
Here's where I am so far.
VB.NET:
Module ApplicationAutomation
Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd _
As Integer) As Integer
Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal _
hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 _
As String) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long
Public Function ApplicationAutomation()
Dim appPID As Integer = Shell("..\main.exe", AppWinStyle.NormalFocus)
Threading.Thread.Sleep(5000)
SetForegroundWindow(appPID)
'Get the main window handle
Dim MWnd As Long = FindWindow("MainClass", vbNullString)
'Get the child window handle
Dim CWnd As Long = THIS IS WHERE I GET CONFUSED
SetForegroundWindow(CWnd) ????
SendKeys.Send(vbCrLf) <--- Need to send a carriage return to the child
End Function
End Module