Autohotkey 热键将另一个热键切换到不同的功能或模式

Autohotkey 热键将另一个热键切换到不同的功能或模式,autohotkey,Autohotkey,我正在尝试使用热键LCTRL将XButton2切换到不同的模式。 问题是它说在同一个脚本中有重复的热键。我显然不知道发生了什么。帮忙 ~LCtrl:: actioncameratoggle := !actioncameratoggle if actioncameratoggle { ~XButton2:: rTurn := !rTurn if rTurn { send {lctrl} mousemove, 800, 450 send {ct

我正在尝试使用热键LCTRL将XButton2切换到不同的模式。 问题是它说在同一个脚本中有重复的热键。我显然不知道发生了什么。帮忙

~LCtrl::
actioncameratoggle := !actioncameratoggle
if actioncameratoggle
{
    ~XButton2::
    rTurn := !rTurn
    if rTurn
    {
    send {lctrl}
    mousemove, 800, 450
    send {ctrl}
    mousemove, 1600, 450
    }
    else
    {

    }
}
else
    {
    ~XButton2::
    {

    }
}
return

谢谢

脚本中不能使用相同的热键进行切换,原因是您希望将ifElse命令一起使用
如果热键1::Else热键1::
,您将需要#if命令。看看这个示例代码

您可以编写这个example.ahk代码并在Windows系统上试用

根据您的需要稍微修改一下代码,就完成了

我确实制作了脚本,以便其他人可以简单地测试它

; [+ = Shift] [! = Alt] [^ = Ctrl] [# = Win] 

a := 1 

#If mode1 ; All hotkeys below this line will only work if mode1 is TRUE or 1
    t::1
    ; Here you can put your first hotkey code ~XButton2::
#If

#If mode2 ; All hotkeys below this line will only work if mode2 is TRUE or 1
    t::2
    ; And here you can put your second hotkey code ~XButton2::
#If

; toggle between [t::1] and [t::2]
;a = 1   => t::1
;a = 2   => t::2

;type LCtrl key to toggle between two the same hotkeys
;you can test it out in notepad - if you then type the key t
~LCtrl::  
if (a=1)
{
mode1 = 1
mode2 = 0
a := 2
}else{
mode1 = 0
mode2 = 1
a := 1
}