I'm trying to develop some code to do a button click onto an application without moving the cursor over to it. I can see messages under Spy++ but nothing happens.
Thanks in advance...
Public Class Form1
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
Const MK_LBUTTON = &H1
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Int32
Private Sub cmdBSPerform_Click(sender As Object, e As EventArgs) Handles cmdBSPerform.Click
Dim hwnd As Long = FindWindow(vbNullString, handle.Text)
Dim lParam As Int32
lParam = MakeLParam(txtXBSPerform.Text, txtYBSPerform.Text)
SendMessage(hwnd, WM_LBUTTONDOWN, WM_LBUTTONUP, MakeLParam(txtXBSPerform.Text, txtYBSPerform.Text))
SendMessage(hwnd, WM_LBUTTONUP, 0, MakeLParam(txtXBSPerform.Text, txtYBSPerform.Text))
End Sub
Public Function MakeLParam(ByVal LoWord As Int32, ByVal HiWord As Int32) As Int32
Return (HiWord << 16) Or (LoWord And &HFFFF)
End Function
End Class