L
Lars Netzel
Hello!
Thanx to this newgroup I have finally, with the help of you guys, gotten
this to work halfway.. but the final action is still not working, clicking
the "Button2" thru SendMessage().
Private Declare Auto Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Auto Function FindWindowEx Lib "user32" (ByVal hWnd1 As
Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As
Long
Private Declare Auto Function SendMessage Lib "user32" (ByVal hwnd As Long,
ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Object) As Long
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Const VK_SPACE = &H20
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles
hWnd = FindWindow(vbNullString, "Form1")
MsgBox("Form1: " & hWnd)
hWndbutton = FindWindowEx(hWnd, 0&, "Button2", vbNullString)
MsgBox("Button2: " & hWndbutton)
'want to send a Click to button number 2 here
MsgBox(SendMessage(hWndbutton, WM_KEYDOWN, VK_SPACE, 0&) & " " &
SendMessage(hWndbutton, WM_KEYUP, VK_SPACE, 0&))
End Sub
I get a long number from both the SendMEssage Calls.. But the Button2 is not
clicked...
Best Regards/
Lars
Thanx to this newgroup I have finally, with the help of you guys, gotten
this to work halfway.. but the final action is still not working, clicking
the "Button2" thru SendMessage().
Private Declare Auto Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Auto Function FindWindowEx Lib "user32" (ByVal hWnd1 As
Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As
Long
Private Declare Auto Function SendMessage Lib "user32" (ByVal hwnd As Long,
ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Object) As Long
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Const VK_SPACE = &H20
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles
hWnd = FindWindow(vbNullString, "Form1")
MsgBox("Form1: " & hWnd)
hWndbutton = FindWindowEx(hWnd, 0&, "Button2", vbNullString)
MsgBox("Button2: " & hWndbutton)
'want to send a Click to button number 2 here
MsgBox(SendMessage(hWndbutton, WM_KEYDOWN, VK_SPACE, 0&) & " " &
SendMessage(hWndbutton, WM_KEYUP, VK_SPACE, 0&))
End Sub
I get a long number from both the SendMEssage Calls.. But the Button2 is not
clicked...
Best Regards/
Lars