用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里的坐标吧,我也试过了,但还是没用,谁有好的后台模拟例子....或者帮我从上面的代码里修改出一个来..
展开
 我来答
ty20me
2007-11-04 · 超过18用户采纳过TA的回答
知道答主
回答量:110
采纳率:0%
帮助的人:0
展开全部
研究下这句lp = lp * 65536 + x 有没有错
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式