在自动热键中使用热键切换键 [英] Toggle a key with hotkey in autohotkey

查看:38
本文介绍了在自动热键中使用热键切换键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我尝试在游戏中自动运行,其中地图很大,而且我必须跑几英里.我想打开热键(Ctrl+Shift+A 或其他东西)按下运行(在游戏中,我可以运行w).我试过代码,比如:

So I tried to automate running in a game, where the map is huge, and I have to run miles. I wanted to toggle on the hotkey (Ctrl+Shift+A or something else) press the running (in the game, I can run with w). I tried code, like:

Pause On
Loop
Send w
+^a::Pause

(它可以按下 w,但不能松开),就像这样:

(it can press the w, but it can't release) and like this:

+^a::
toggle := !toggle

while toggle
    Send {w down}

(同样的问题).只是我的问题,还是这些代码有问题?

(same problem). It's just my problem, or these codes are wrong?

推荐答案

这是我的股票功能.我通常将它映射到 ^W 或 Q.按 w 或 s 将取消它.轻轻松松.

This is my stock function. I usualy map it to ^W or Q. Pressing w or s will cancel it. Easy peasy.

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

这篇关于在自动热键中使用热键切换键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆