Reputation: 21
I'm trying to get a the hotkey LCTRL to toggle XButton2 into different modes. The issue is that it's saying that there are duplicate hotkeys in the same script. I clearly don't know what's going on. Help?
~LCtrl::
actioncameratoggle := !actioncameratoggle
if actioncameratoggle
{
~XButton2::
rTurn := !rTurn
if rTurn
{
send {lctrl}
mousemove, 800, 450
send {ctrl}
mousemove, 1600, 450
}
else
{
}
}
else
{
~XButton2::
{
}
}
return
Thanks!
Upvotes: 2
Views: 300
Reputation: 130
With your Script You can not toggle with the same hotkeys, the reason is you want to use the if with the Else commands > if hotkey1:: else hotkey1::
, you will need the #if commands. Look to this example code.
You can Write this example.ahk Code and try it out on your Windows System.
Change the code a little bit for your needs, and it is done.
I did make the script so that the other guys can simple test it out.
; [+ = 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
}
Upvotes: 1