我在函数中的autohotkey中有以下while循环:
foo(){
counter:=1
while(counter<10)
{
send, %counter%
Random, SleepAmount, 2300, 3300
sleep, 3000
counter++
}
}
我希望能够通过按{Ctrl}
来停止循环。什么是实现目标的最佳方式?
答案 0 :(得分:1)
以这种方式尝试:
F1:: foo()
foo(){
counter := 1
while(counter < 10)
{
send, %counter%
Random, SleepAmount, 23, 33
loop 100
{
Sleep, %SleepAmount%
If GetKeyState("Ctrl", "P")
return
}
counter++
}
}
答案 1 :(得分:0)
~Ctrl::counter := 10
F1:: foo()
foo(){
global counter:=1
while(counter<10)
{
send, %counter%
Random, SleepAmount, 2300, 3300
sleep, SleepAmount
counter++
}
}