首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

SendMessage 到指定的窗口 發送點擊的信息 可昰座標信息不對解决思路

2012-02-20 
SendMessage 到指定的窗口 發送點擊的信息 可昰座標信息不對我自個寫了個代碼我用SPY++ 去監控我想要控制

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++去監控

VB code
<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


xPos 和 yPos 都亂跳 沒有照我定義的輸入到這個窗口 這邊想要請教各位大爺

該怎麼修改我的代碼 才能得到我想要的座標呢?

[解决办法]
(mX And &HFFFF) + (my And &HFFFF) * &H10000
这样计算是正确的吗?单步调试看看

为什么不用POINTS结构(MAKEPOINTS也行)传这个坐标呢?参考MSDN中的WM_LBUTTONDOWN 

[解决办法]
'VB要传POINTS还有点麻烦,参考下面这个吧

VB code
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 

热点排行