码迷,mamicode.com
首页 > 其他好文 > 详细

VB检测按键CTRL+C的次数

时间:2016-12-19 18:56:56      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:declare   get   img   virt   cti   ges   清零   表示   ima   

技术分享

 

 

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

 

VB检测按键CTRL+C的次数

标签:declare   get   img   virt   cti   ges   清零   表示   ima   

原文地址:http://www.cnblogs.com/liuzhaoyzz/p/6198256.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!