VB 如果获取小键盘的加号被长时间按住

来源:百度知道 编辑:UC知道 时间:2024/05/26 19:23:19
如题!知者回答.

还有一点就是,如果程序不是当前的活动窗口呢,keydown和keyup似乎是不能应用的。
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Private Sub Form_Load()
Text1.Text = ""
End Sub

Private Sub Timer1_Timer()
KeyResult = GetAsyncKeyState(107)
If KeyResult = -32767 Then
AddKey = "+"
Text1 = Text1 & AddKey
End If
If Len(Text1.Text) > 8 Then
MsgBox "按键时间过长"
Text1.Text = ""
End If
End Sub
这个能检测到按下,不过不能检测到松开。

KeyDown和KeyUp的就可以中间加计时 在用布尔类型的数值做开关!
明白??

用键盘钩子监控键盘。