3个回答
展开全部
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
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
展开全部
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怎么用吧
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怎么用吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询