VB里鼠标单击

求段代码,当我按下F2的时候,鼠标每隔X毫秒左击一次~... 求段代码,当我按下F2的时候,鼠标每隔X毫秒左击一次~ 展开
 我来答
12105412
2012-09-23 · TA获得超过817个赞
知道小有建树答主
回答量:1349
采纳率:0%
帮助的人:829万
展开全部
1、声明API
Public 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)
Public Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal y As Long) As Long
Public Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
Public Const MOUSEEVENTF_LEFTUP = &H4 ' left button up
'timer的时间设置为2000 将下面这句话放进去
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
SRS99D
2012-09-23
知道答主
回答量:1
采纳率:0%
帮助的人:1569
展开全部
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)
Private Const MOUSEEVENTF_LEFTDOWN = &H2

Private s As Boolean
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF2 Then
If s = False Then
Timer1.Enabled = True
Else
Timer1.Enabled = False
End If
End If
End Sub

Private Sub timer1_timer()
mouse_event MOUSEEVENTF_LEFTDOWN, x, y, 0, 0
End Sub

知道timer怎么用吧
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
风雪剑无痕
2012-09-23 · TA获得超过1253个赞
知道大有可为答主
回答量:1691
采纳率:100%
帮助的人:1662万
展开全部
Private Declare Function GetAsyncKeyState Lib "User32" (ByVal Vkey As Long) As Integer
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 Sub Form_Load()
Timer1.Interval = 10 '每隔X毫秒
End Sub
Private Function MyHotKey(vKeyCode) As Boolean
MyHotKey = GetAsyncKeyState(vKeyCode) < 0
End Function
Private Sub Timer1_Timer()
If MyHotKey(vbKeyF2) Then '当按下F2
PostMessage Command2.hwnd, &HF5, &H1, x + y '鼠标左击一次
End If
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式