不一定要用hook,但是hook很准,如果不是特殊情况,你可以试试这个: 加一个Timer,Interval时间间隔设成小于半秒比如300 Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer Private Sub Timer1_Timer() Dim x As Long x = GetAsyncKeyState(1) '左键 If x = -32767 Then Debug.Print "左键" End Ifx = GetAsyncKeyState(2) '右键 If x = -32767 Then Debug.Print "右键" End If End Sub
加一个Timer,Interval时间间隔设成小于半秒比如300
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Timer1_Timer()
Dim x As Long
x = GetAsyncKeyState(1) '左键
If x = -32767 Then
Debug.Print "左键"
End Ifx = GetAsyncKeyState(2) '右键
If x = -32767 Then
Debug.Print "右键"
End If
End Sub
http://www.sijiqing.com/vbgood/forum/forum_posts.asp?TID=13586&PN=1