楼主的要求是按下F6,按键精灵持续按X,所以楼上的代码无法满足要求,还需要一个检测目标按键状态的过程,代码如下:
=============================
Declare Function GetAsyncKeyState Lib "user32" Alias "GetAsyncKeyState" (ByVal vKey As Long) As Integer
DimEnv need
BeginThread x
While 1
n = GetAsyncKeyState(117)
If n = 1 Then //弹起F6了
KeyUp "ctrl", 1
need=0
ElseIf n < 0 Then //处于按下F6状态
KeyDown "ctrl", 1
need=1
Else //F6无动作
End If
Delay 500
Wend
//进程:敲X
Sub x
While 1
While need
KeyPress "X", 1
Delay 300
Wend
Delay 500
Wend
End Sub
==============================
这段代码使用了windows的API:GetAsyncKeyState来判断按键的状态
此外使用了多线程操作,主线程检测F6状态,另一个线程按X键
希望对你有帮助,如果有啥不懂的欢迎来想我追问~
^o^
Rem xxxxx
Key = WaitKey()
If Key = (F6的按键码) Then
KeyDown "Control",1
Do
KeyPress "X",1
Loop
Else
Goto xxxxx
End If
私信我。解决