在autohotkey中使用热键切换键

时间:2013-10-07 18:47:27

标签: loops toggle autohotkey hotkeys

所以我试图在游戏中自动运行,地图很大,而且我必须运行里程。我想切换热键( Ctrl + Shift + A 或其他)按下运行(在游戏中,我可以运行瓦特)。 我试过代码,比如:

Pause On
Loop
Send w
+^a::Pause

(它可以按w,但不能释放)并且像这样:

+^a::
toggle := !toggle

while toggle
    Send {w down}

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

5 个答案:

答案 0 :(得分:1)

我有一个(至少我认为)更简单的解决方案:)

#NoTrayIcon

ScrollLock::

    Input, Key, ,{Enter}

    Send, {%Key% Down}

return

你按ScrollLock(我怀疑你用于其他任何东西,否则将其设置为一个空闲键),然后输入要按住的按钮名称。

  • 如果您想要按住一个字符,只需将其写入。
  • 对于其他按键,您可以在此处找到名称:http://www.autohotkey.com/docs/KeyList.htm
  • 鼠标:LButton为左,RButton为右,MButton为中

您使用Enter键结束输入,然后程序将按住输入的键。

如果你想“抬起”钥匙,只需按一下,它就不会再按下了。 :)

ps.:我有#NoTrayIcon,因为我在后台永久运行它,但如果你想退出,那么只需添加如下内容:

F12::
    ExitApp
return

答案 1 :(得分:0)

+^vk41:: ; shift+ctrl+a
   SetTimer, % "SomeLable", % (bToggle:=!bToggle) ? 25:"Off"
   KeyWait, % "vk41"
   Return

SomeLable:
   SendInput, % "{vk57}" ; w
   Return

答案 2 :(得分: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
        }
    }
}

答案 3 :(得分:0)

一个愚蠢的noob示例,其中F10是切换热键,而向上/向下状态是变量。需要预先声明变量以给出初始值。

说实话,我期待一条错误信息,但似乎运行正常。

keystate=down

F10::
Send {w %keystate%}
if keystate = down
SetEnv, keystate, up
else if keystate = up
SetEnv, keystate, down
return

答案 4 :(得分:0)

Toggle      := 1
Q::Send, % Toggle = 1 ? ( "0", Toggle := 0 ) : ( "9", Toggle := 1 )

将Q更改为您首选的热键,然后更改" 0"和" 9"到您要切换的键。确保将你的能力或武器设置为你在" 0"中替换的键。和" 9"。

所以,让我说我有一个主要和次要武器。我在游戏中将它们绑定到9和0。

我按Q在它们之间循环以进行快速武器切换。或者你想要的其他东西。