7,763
社区成员
发帖
与我相关
我的任务
分享
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Function GetCapture Lib "user32" () As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyEscape Then
x = ReleaseCapture()
MsgBox x
End If
End Sub
Private Sub Form_Load()
Timer1.Interval = 100
GetCapture
End Sub
Private Sub Timer1_Timer()
x = GetAsyncKeyState(1) '获得左键状态
If x = -32767 Then
MsgBox "我点击了左键!"
Exit Sub
End If
x = GetAsyncKeyState(2) '获得右键状态
If x = -32767 Then
MsgBox "我点击了右键!"
Exit Sub
End If
End Sub