Problem with SendMessage(WM_RBUTTONDOWN)

  • Thread starter Thread starter Jean Psdlw
  • Start date Start date
J

Jean Psdlw

Guest
Hello, my code works correctly to click at x25 y80, but only clicks if the application is minimized or in focus, if the cursor is outside of the appwindow in the background does not work, and if another appwindow is at the top hiding, click the location that My cursor is.



<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)>
Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
End Function

Private Declare Function SendMessage1 Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long,
ByVal wParam As Long, ByVal lParam As Long) As Long

Private Function MakeDWord(ByVal LoWord As Integer, ByVal HiWord As Integer) As Long
MakeDWord = (HiWord * &H10000) Or (LoWord And &HFFFF&)
End Function

Private Const WM_SYSKEYDOWN = &H104
Private Const WM_SYSKEYUP = &H105
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Const VK_SPACE = &H20
Private Const VK_CONTROL = &H11
Private Const VK_LEFT = &H25
Private Const VK_UP = &H26
Private Const VK_RIGHT = &H27
Private Const VK_DOWN = &H28

Private Const WM_MOUSEMOVE = &H200
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Const WM_RBUTTONDOWN = &H204
Private Const WM_RBUTTONUP = &H205



Dim title As String
Dim handle As IntPtr
Dim clt As Process = Process.GetProcessById(ProcessID)
Dim coord = MakeDWord(25, 80)
title = clt.MainWindowTitle
handle = clt.MainWindowHandle

SendMessage(handle, WM_MOUSEMOVE, 0, coord)
SendMessage(handle, WM_RBUTTONDOWN, &H2, coord)
SendMessage(handle, WM_MOUSEMOVE, &H2, coord)
SendMessage(handle, WM_LBUTTONUP, 0, coord)
SendMessage(handle, WM_MOUSEMOVE, 0, coord)

What happens? Why it just work focused with the cursor in the range of the appwindow or minimized?

Continue reading...
 
Back
Top