3个回答
展开全部
可以使用API函数mouse_event实现鼠标动作,包括单击,移动等。
如:
Option Explicit
Private Declare Sub mouse_event Lib "user32 " (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Const MOUSEEVENTF_LEFTDOWN = &H2
Const MOUSEEVENTF_LEFTUP = &H4
Const MOUSEEVENTF_MOVE = &H1
Const MOUSEEVENTF_ABSOLUTE = &H8000
Private lngClickCount as long
'定时在100,120处单击鼠标左右,次数5次
Private Sub Timer1_Timer()
If lngClickCount = 5 then
Timer1.Enabled = False
Exit Sub
End If
lngClickCount = lngClickCount + 1
mouse_event MOUSEEVENTF_MOVE Or MOUSEEVENTF_ABSOLUTE, 100& * 65535 / 1024, 120 * 65535 /768, 0&, 0& '假设屏幕分辨率是1024*768,移动到(100,120)坐标点
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP Or MOUSEEVENTF_ABSOLUTE, 0, 0, 0&, 0& '如果把这句再重复一下就是双击了
End Sub
具体参考下面的链接。
如:
Option Explicit
Private Declare Sub mouse_event Lib "user32 " (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Const MOUSEEVENTF_LEFTDOWN = &H2
Const MOUSEEVENTF_LEFTUP = &H4
Const MOUSEEVENTF_MOVE = &H1
Const MOUSEEVENTF_ABSOLUTE = &H8000
Private lngClickCount as long
'定时在100,120处单击鼠标左右,次数5次
Private Sub Timer1_Timer()
If lngClickCount = 5 then
Timer1.Enabled = False
Exit Sub
End If
lngClickCount = lngClickCount + 1
mouse_event MOUSEEVENTF_MOVE Or MOUSEEVENTF_ABSOLUTE, 100& * 65535 / 1024, 120 * 65535 /768, 0&, 0& '假设屏幕分辨率是1024*768,移动到(100,120)坐标点
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP Or MOUSEEVENTF_ABSOLUTE, 0, 0, 0&, 0& '如果把这句再重复一下就是双击了
End Sub
具体参考下面的链接。
参考资料: http://boynd.muicc.com/vb/API/mouseapi.htm
展开全部
vb 不是很了解,不过应该 有类似与mouse_down之类的事件吧。鼠标单击 一次 同时启动计时器,在计时器时间隔内 ,点几次,设定一个变量加上去,计时器到了,就清0;;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1.用mouse_event函数模拟
Public Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
2.用SendMessage或PostMessage发送WM_LBUTTONDOWN和WM_LBUTTONUP消息。
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public 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
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
2.用SendMessage或PostMessage发送WM_LBUTTONDOWN和WM_LBUTTONUP消息。
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public 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
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询