展开全部
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
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 Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
Private Const MOUSEEVENTF_LEFTUP = &H4 ' left button up
Dim key1 As Integer
Dim key2 As Integer
Dim bolStage As Boolean
Dim lngTimer As Long
Private Sub Form_Load()
Timer1.Interval = 10
Timer1.Enabled = True
'Me.Visible = False
key1 = GetKeyState(vbKeyF11)
key2 = GetKeyState(vbKeyF12)
lngTimer = GetTickCount
End Sub
Private Sub Timer1_Timer()
If GetKeyState(vbKeyF11) <> key1 Then key1 = GetKeyState(vbKeyF11): bolStage = True: Beep
If GetKeyState(vbKeyF12) <> key2 Then key2 = GetKeyState(vbKeyF12): bolStage = False: Beep
'按F11开启功能,按F12关闭功能,如果不需要这样,将上两行删除即可
If bolStage And (GetTickCount - lngTimer) >= 1000 Then '此处的1000表示每一秒执行一次,如有改动修改此参数即可。
lngTimer = GetTickCount
'SetCursorPos 288, 718 '设置鼠标位置(1024X768)
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 '单击时用左按键下or左按键上,双击时写两句
End If
End Sub
在窗体添加一个Timer控件并将上述代码复制上就行了。
更多追问追答
追问
这不是驱动级的吧
追答
否,用的是API
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询