请问VB中如何实现后台操作鼠标??可以用哪几种方法?如何用postmessage

我已经找到了:OptionExplicitPublicDeclareSubSleepLib"kernel32"(ByValdwMillisecondsAsLong)Pub... 我已经找到了:
Option Explicit
Public Declare Sub Sleep Lib "kernel32 " (ByVal dwMilliseconds As Long)
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const MK_LBUTTON = &H1
Dim mypos As Long

Public Sub MouseEvent(hwnd As Long, x As Long, y As Long)

mypos = y * &H10000 Or x
'PostMessage hwnd, WM_MouseMove, 0, ByVal mypos
PostMessage hwnd, WM_LBUTTONDOWN, 1, ByVal mypos
Sleep 200
PostMessage hwnd, WM_LBUTTONUP, 0, ByVal mypos

End Sub
展开
 我来答
ccccmmmmdddd
2012-03-13 · TA获得超过1189个赞
知道小有建树答主
回答量:225
采纳率:100%
帮助的人:173万
展开全部
不一定要用这个
Private Declare Function SetCursorPos Lib "user32" (ByVal a As Long, ByVal b As Long) As Long

Private Sub Form_Load()
SetCursorPos 100, 100
End Sub
这个是移动鼠标
Private Declare Sub mouse_event Lib "user32" (ByVal a As Long, ByVal b As Long, ByVal c As Long, ByVal d As Long, ByVal e As Long)

Private Sub Form_Load()
mouse_event &H2, 0, 0, 0, 0
End Sub
&H2是参数
&H2代表按住鼠标左键
&H4代表松开鼠标左键
&H8代表按住鼠标右键
&H10代表松开鼠标右键
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
tuandiao36
2012-03-13
知道答主
回答量:11
采纳率:0%
帮助的人:7万
展开全部
涉及到后台操作,必须用postmessage 如能解决,可以加更多分~ 谁能帮我实现一个在VB中webbrowser控件的鼠标手势功能,或者是用一个按钮点Dim h
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
zx001z7d53
2012-03-13 · TA获得超过2万个赞
知道大有可为答主
回答量:2.4万
采纳率:52%
帮助的人:5641万
展开全部
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 Long
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Sub Command1_Click()
MsgBox "123"
End Sub

Private Sub Command2_Click()
PostMessage Command1.hwnd, WM_LBUTTONDOWN, 0, 0
PostMessage Command1.hwnd, WM_LBUTTONUP, 0, 0
End Sub
本回答被提问者和网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式