陈晓猫

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: :: 管理 ::

 

 

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Public chongfu As Integer

Private Sub Timer1_Timer()
Timer1.Interval = 50
X = GetKeyState(vbKeyC)
y = GetKeyState(vbKeyControl)
' X = GetAsyncKeyState(vbKeyC)
' y = GetAsyncKeyState(vbKeyControl)
Cls
If X < 0 Then
Print "按住了c " & X
Else
Print "没按住c " & X
End If

If y < 0 Then
Print "按住了ctrl " & y
Else
Print "没按住ctrl " & y
End If

If X < 0 And y < 0 And chongfu = 0 Then '当ctrl+c按下并且重复次数为0,caption加个C
Me.Caption = Me.Caption & "C"
chongfu = 1 '加个C之后,把重复次数变成1,表示重复多次
ElseIf X >= 0 Then '如果C键弹起就把重复次数清零
chongfu = 0
End If
End Sub

 

posted on 2016-12-19 17:19  陈晓猫  阅读(1192)  评论(0编辑  收藏  举报