使用自动热键中的热键切换键

And*_*szl 5 loops autohotkey hotkeys toggle

所以我尝试在游戏中自动运行,地图很大,我必须跑几英里。我想打开热键(Ctrl+ Shift+A或其他键)按运行(在游戏中,我可以使用 运行w)。我尝试了代码,例如:

Pause On
Loop
Send w
+^a::Pause
Run Code Online (Sandbox Code Playgroud)

(它可以按 w,但无法释放)如下所示:

+^a::
toggle := !toggle

while toggle
    Send {w down}
Run Code Online (Sandbox Code Playgroud)

(同样的问题)。这只是我的问题,还是这些代码是错误的?

Pro*_*aul 0

这是我的股票功能。我通常将其映射到 ^W 或 Q。按 w 或 s 将取消它。十分简单。

HoldW(){
    SendInput {w up}{w down}
    Loop
    {
        Sleep 100
        GetKeyState state, w
        if state = u
            return
        If GetKeyState("s")
        {
            SendInput {w up}
            return
        }
    }
}
Run Code Online (Sandbox Code Playgroud)