请问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 展开
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 展开
展开全部
不一定要用这个
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代表松开鼠标右键
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代表松开鼠标右键
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
涉及到后台操作,必须用postmessage 如能解决,可以加更多分~ 谁能帮我实现一个在VB中webbrowser控件的鼠标手势功能,或者是用一个按钮点Dim h
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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
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
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询