用postmessage模拟后台鼠标点击的问题 20
form1:PrivateConstWM_LBUTTONDOWN=&H201PrivateConstWM_LBUTTONUP=&H202PrivateConstVK_CO...
form1:
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Const VK_CONTROL = &H11
Private Const VK_SHIFT = &H10
Private Const VK_RETURN = &HD
Private Const VK_1 = &H31
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Sub Command1_Click()
Dim lp As Long, hwnd As Long
hwnd=xxx
lp = y
lp = lp * 65536 + x '上面的X和Y代表的是你要在指定的窗口中执行鼠标事件的一个点的坐标
PostMessage hwnd, WM_LBUTTONDOWN, MK_LBUTTON, lp
PostMessage hwnd, WM_LBUTTONUP, MK_LBUTTON, lp '在窗口(hwnd)中的点(x,Y)执行一次鼠标单击事件
End Sub
module1:
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public Const WM_CHAR = &H102
Public Const VK_C = 67
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const WM_MOUSEMOVE = &H200
Public Const MK_LBUTTON = &H1
Public Const MK_MBUTTON = &H10
Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" (ByVal wCode As Long, ByVal wMapType As Long) As Long
==============================================================
上面这段代码,为什么我执行起来不能够实现鼠标点击.
hwnd的xxx我是给了指定窗口的句柄了的.
但还是不能模拟后台...这是为什么.....
这里的x,y是hwnd里的坐标吧,我也试过了,但还是没用,谁有好的后台模拟例子....或者帮我从上面的代码里修改出一个来.. 展开
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Const VK_CONTROL = &H11
Private Const VK_SHIFT = &H10
Private Const VK_RETURN = &HD
Private Const VK_1 = &H31
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Sub Command1_Click()
Dim lp As Long, hwnd As Long
hwnd=xxx
lp = y
lp = lp * 65536 + x '上面的X和Y代表的是你要在指定的窗口中执行鼠标事件的一个点的坐标
PostMessage hwnd, WM_LBUTTONDOWN, MK_LBUTTON, lp
PostMessage hwnd, WM_LBUTTONUP, MK_LBUTTON, lp '在窗口(hwnd)中的点(x,Y)执行一次鼠标单击事件
End Sub
module1:
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public Const WM_CHAR = &H102
Public Const VK_C = 67
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const WM_MOUSEMOVE = &H200
Public Const MK_LBUTTON = &H1
Public Const MK_MBUTTON = &H10
Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" (ByVal wCode As Long, ByVal wMapType As Long) As Long
==============================================================
上面这段代码,为什么我执行起来不能够实现鼠标点击.
hwnd的xxx我是给了指定窗口的句柄了的.
但还是不能模拟后台...这是为什么.....
这里的x,y是hwnd里的坐标吧,我也试过了,但还是没用,谁有好的后台模拟例子....或者帮我从上面的代码里修改出一个来.. 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询