无法在循环中执行任何其他操作

Cant perform any other actions while in loop

功能:我希望脚本循环 F5 来为我刷新页面,当我看到不错的东西时,我按其他键之一来狙击一个项目。

问题:在循环 F5 时我无法执行任何其他脚本。

MouseGetPos, OrigX, OrigY
mouseClick, left
sleep 20
random, randomlocx , 0,5
random, randomlocy , 0,5
MouseMove, 1162+randomlocx, 477+randomlocy, 0
mouseClick, left
sleep 10
send {y}
random, randomlocx2 , 0,10
random, randomlocy2 , 0,10
MouseMove, OrigX+randomlocx2, OrigY+randomlocy2, 0
return

2::
MouseGetPos, OrigX, OrigY
random, randomlocx , 0,5
random, randomlocy , 0,5
MouseMove, 964+randomlocx, 575+randomlocy, 0
sleep 20
mouseClick, left
MouseMove, OrigX, OrigY, 0

~$F5::
loop , 300 
{
Send {F5}
}   
return
F12::Reload   ; Reload script```

AutoHotkey 不提供真正的多线程,这就是为什么您的脚本在有循环时无法响应的原因 运行。
要解决这个问题,您需要使用 Timer。循环真的不适合这个东西。

一键切换定时器的例子on/off:

F5::
    toggle := !toggle ;a convenient way to toggle a variable in AHK, see below of explanation
    if(toggle) ;if true
        SetTimer, TimerCallback, 100 ;callback every ~100ms
    else
        SetTimer, TimerCallback, Off ;turn off timer
return

TimerCallback() ;the callback function
{
    Tooltip, % A_TickCount
}

toggle := !toggle变量状态切换的解释可以从我之前的回答中找到here
还包括一个可爱的小 1liner 定时器切换热键的示例。