这个要调用系统API才能实现,实现代码如下
Declare Function GetAsyncKeyState Lib "user32" Alias "GetAsyncKeyState" (ByVal vKey As Long) As Integer
Dim key, n
key = 112//F1的按键码=112
WaitKey
Do
n = GetAsyncKeyState(key)
If n < 0 Then
KeyPress "F1", 1
Delay 200
RestartScript
Else
RestartScript
End If
Delay 500
Loop