I'm somewhat new to AutoHotKey. I made a toggleable macro that maps the WASD keys to the arrow keys.
The original code works but I'm trying to enable the hotkeys with a loop which is currently giving me a Nonexistent Hotkey error. How can I fix this loop, so that it works like the hard-coded nightmare below it?
for i in macros {
Hotkey, % keys[i], % macros[i], % state ; <<< This line is causing the error
}
arrowsActive := 0
; CTRL + WASD --> arrow keys
Enter::
arrowsActive := not arrowsActive
macros := [arrowUp1, arrowLeft1, arrowDown1, arrowRight1, arrowUp2, arrowLeft2, arrowDown2, arrowRight2]
keys := [W, A, S, D, W, A, S, D]
state = Off
if arrowsActive {
state = On
}
for i in macros {
Hotkey, % keys[i], % macros[i], % state
}
;Hotkey, W, arrowUp1, state
;Hotkey, A, arrowLeft1, state
;Hotkey, S, arrowDown1, state
;Hotkey, D, arrowRight1, state
;Hotkey, W Up, arrowUp2, state
;Hotkey, A Up, arrowLeft2, state
;Hotkey, S Up, arrowDown2, state
;Hotkey, D Up, arrowRight2, state
Return
arrowUp1:
send, {Up Down}
Return
arrowUp2:
send, {Up Up}
Return
arrowLeft1:
send, {Left Down}
Return
arrowLeft2:
send, {Left Up}
Return
arrowDown1:
send, {Down Down}
Return
arrowDown2:
send, {Down Up}
Return
arrowRight1:
send, {Right Down}
Return
arrowRight2:
send, {Right Up}
Return