Loops 如何使用启动自动热键的键停止自动热键中的无限循环
所以我刚开始使用自动热键,我制作了这个脚本,在一个名为“放逐之路”的游戏中垃圾邮件交易聊天,它工作得很好,但当我再次按f1时,我无法停止它,我尝试了很多次,但循环就是不会停止Loops 如何使用启动自动热键的键停止自动热键中的无限循环,loops,toggle,autohotkey,Loops,Toggle,Autohotkey,所以我刚开始使用自动热键,我制作了这个脚本,在一个名为“放逐之路”的游戏中垃圾邮件交易聊天,它工作得很好,但当我再次按f1时,我无法停止它,我尝试了很多次,但循环就是不会停止 #MaxThreads 2 wintitle=Path of Exile SetTitleMatchMode,2 DetectHiddenWindows,On setkeydelay,2500,0 f1:: toggle:=!toggle Loop { if toggle controlsend,,{enter
#MaxThreads 2
wintitle=Path of Exile
SetTitleMatchMode,2
DetectHiddenWindows,On
setkeydelay,2500,0
f1::
toggle:=!toggle
Loop
{
if toggle
controlsend,,{enter}{up}{enter}, %wintitle%
else
break
}
return
使用
MaxThreadsPerHotkey
#MaxThreadsPerHotkey 2
wintitle=Path of Exile
SetTitleMatchMode,2
DetectHiddenWindows,On
setkeydelay,2500,0
return
f1::
toggle:=!toggle
Loop
{
if toggle
controlsend,,{enter}{up}{enter}, %wintitle%
else
break
}
return
我想你最好用这个。当涉及到切换时,循环并不容易使用
i := 0
toggle := 0
F1::
toggle := !toggle
if (toggle) {
SetTimer, Timer_Spam, 10
} else {
SetTImer, Timer_Spam, Off
}
return
Timer_Spam:
TrayTip, Counter, %i%
i++
return
循环不起作用的原因是,一旦你进入循环,程序就会卡在那里,所以要想退出,你需要从循环内部开始工作
您可以使用来执行此操作,但不能使用同一个键来打开和关闭它,因为它会在启动后立即关闭,除非您在其中添加Sleep
命令,否则它会变得不可靠
但是,您可以使用单独的键来停止循环,如图所示
toggle := 0
i := 0
F1::
toggle := !toggle
if (toggle) {
Loop {
if (GetKeyState("F2", "P")) {
toggle := !toggle
break
}
TrayTip, Counter, %i%
i++
}
}
return
但正如我上面所说,
SetTimer
以更稳定的方式实现了相同的结果。所以我同意这一点。此代码满足您的要求:
#MaxThreads 2
wintitle=Path of Exile
SetTitleMatchMode,2
DetectHiddenWindows,On
setkeydelay,2500,0
return
F1::
Loop
{
CheckLButton1:
if (GetKeyState("F1"))
{
Goto, CheckLButton1
}
Docode:
controlsend,,{enter}{up}{enter}, %wintitle%
;ToolTip, 1
if (!(GetKeyState("F1")))
{
Goto, Docode
}
CheckLButton2:
if (!(GetKeyState("F1")))
{
return
}
else
{
Goto, CheckLButton2
}
}
return
如果你需要解释,请看我的帖子:我的策略是,
使用此命令:
v::
loop
{
click
if (GetKeyState("b")) {
break
}
}
return
(它是一个简单的自动点击器)使用Loop命令的工作示例。但这很简单
#Persistent
#MaxThreadsPerHotkey 2
toggle := False
f1 UP::
toggle := !toggle
Loop {
If (!toggle) {
break
}
; Spam commands here
}
Return
这是我能做到的最简单的方法 使用“2”键启动/停止切换,以0.1秒的延迟发送“a”
#MaxThreadsPerHotkey 2
running := false
stop := false
~2::
if(!running) {
running := true
}
else {
stop := true
return
}
loop {
Send {a} ; example sending key "a"
if(stop) {
running := false
stop := false
break
}
Sleep, 100
}
return
谢谢你的回复,我试过了,但还是不起作用-再次按下f1键后循环继续进行感谢帮助者,我真的很感激,你的第二个代码起作用了,我所要做的就是按住f2键