SendMessage 到指定的窗口 發送點擊的信息 可昰座標信息不對
我自個寫了個代碼
我用SPY++ 去監控我想要控制的窗口
想發送點擊的信息 這邊的座標信息 就是不對
SendMessage(hwnd2, WM_LBUTTONDOWN, 0, (mX And &HFFFF) + (my And &HFFFF) * &H10000)
SendMessage(hwnd2, WM_LBUTTONUP, 0, (mX And &HFFFF) + (my And &HFFFF) * &H10000)
我指定的座標應該是這個值 xPos:136 yPos:31
可是我用SPY++去監控
<00001> 00050AEA S WM_LBUTTONDOWN fwKeys:0000 xPos:19336 yPos:430 [wParam:00000000 lParam:01AE4B88]<00002> 00050AEA R WM_LBUTTONDOWN lResult:00000000<00003> 00050AEA S WM_LBUTTONUP fwKeys:0000 xPos:19592 yPos:430 [wParam:00000000 lParam:01AE4C88]<00004> 00050AEA R WM_LBUTTONUP lResult:00000000<00005> 00050AEA S WM_LBUTTONDOWN fwKeys:0000 xPos:-2492 yPos:430 [wParam:00000000 lParam:01AEF644]<00006> 00050AEA R WM_LBUTTONDOWN lResult:00000000<00007> 00050AEA S WM_LBUTTONUP fwKeys:0000 xPos:-2476 yPos:430 [wParam:00000000 lParam:01AEF654]<00008> 00050AEA R WM_LBUTTONUP lResult:00000000<00009> 00050AEA S WM_LBUTTONDOWN fwKeys:0000 xPos:-3696 yPos:428 [wParam:00000000 lParam:01ACF190]<00010> 00050AEA R WM_LBUTTONDOWN lResult:00000000<00011> 00050AEA S WM_LBUTTONUP fwKeys:0000 xPos:-3680 yPos:428 [wParam:00000000 lParam:01ACF1A0]<00012> 00050AEA R WM_LBUTTONUP lResult:00000000<00013> 00050AEA S WM_LBUTTONDOWN fwKeys:0000 xPos:29756 yPos:429 [wParam:00000000 lParam:01AD743C]<00014> 00050AEA R WM_LBUTTONDOWN lResult:00000000<00015> 00050AEA S WM_LBUTTONUP fwKeys:0000 xPos:29772 yPos:429 [wParam:00000000 lParam:01AD744C]<00016> 00050AEA R WM_LBUTTONUP lResult:00000000
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _ (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As LongConst MK_LBUTTON = &H1Const WM_LBUTTONDOWN = &H201Const WM_LBUTTONUP = &H202Private Sub Command1_Click() Dim a As Long Dim x As Integer, y As Integer x = 136 / 15 'xPos, yPos只能是15的倍数,且要先除以15 y = 31 / 15 a = x + y * &H10000 PostMessage hwnd2, WM_LBUTTONDOWN, MK_LBUTTON, a PostMessage hwnd2, WM_LBUTTONUP, MK_LBUTTON, aEnd Sub