,
Declare Function GetAsyncKeyState Lib "user32" Alias "GetAsyncKeyState" (ByVal vKey As Long) As Integer
Dim key, n
key = 65'A的按键码=65
Do
n = GetAsyncKeyState(key)
If n = 1 Then
TracePrint "按了" & Chr(key) & "键"
ElseIf n < 0 Then
TracePrint "按住了" & Chr(key) & "键"
KeyDown "B", 1'只有按下,没有按住
Else
TracePrint "无按键,等待!"
KeyUp "B", 1
End If
Delay 500
Loop