Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
//这一句是一行
While True
If GetAsyncKeyState(32) <> 0 Then //32是Space的ASCII码,不等于0表示按下,等于0表示弹起
//这里写你要执行的代码
Else
Delay 5 //延时是为了减少当按键没有按下或者弹起时,CPU负担
End If
Wend
首先,Key是一个变量,keyup是指令,这两个不能换
Key = GetLastKey()
If Key = 32 Then
Delay 110
key2=waitkey()
Do While key2=key
Loop
KeyPress "q", 1
End If