AHK script with Modifiers while World of Warcraft is active

AUTOHOT KEY

I dont use it, but when i used it, before i bought my self Corsair keyboard, or Razer keyboard, where it possible to use macros on buttons to set to “while pressed”. I always where looking for this…

Often in GSE macros, there is set modifiers on the keypress or sequence. Then its often more effecient to use modifiers on proc’s than release and press another button.

This is script for AHK that works with modifiers…
The “q” and “e” and speed 50 is what u need to change to ur own specs. q and e is my 2 spam buttons and speed is ms u wanna spam the buttons while u keep it pressed.

#ifWinActive World of Warcraft
{
$q::
$^q::
$+q::
$!q::
Loop
{
if not GetKeyState("q", "P")
break
if GetKeyState("LCtrl", "P")
Send ^q
else if GetKeyState("LShift", "P")
Send +q
else if GetKeyState("LAlt", "P")
Send !q
else
Send q
sleep 50
}
return
}
{
$e::
$^e::
$+e::
$!e::
Loop
{
if not GetKeyState("e", "P")
break
if GetKeyState("LCtrl", "P")
Send ^e
else if GetKeyState("LShift", "P")
Send +e
else if GetKeyState("LAlt", "P")
Send !e
else
Send e
sleep 50
}
return
}    

Just change the Q’s or E’s that i use, to what ever u wanna use…

Is there a way to have the macro work with modifiers and toggle instead of keypress? This would be very nice! I am more used to a toggle macro instead of having to keep the button pressed forever.

This is my similar script:

#IfWinActive World of Warcraft

toggle1 := 0
toggle2 := 0

SetTimer, PressKey1, 100
SetTimer, PressKey2, 100

$*1::toggle1 := !toggle1
$*2::toggle2 := !toggle2

PressKey1:
If toggle1
{
toggle2 := 0
If GetKeyState(“Control”, “P”) && GetKeyState(“Shift”)
Send +^1
Else If GetKeyState(“Control”, “P”)
Send ^1
Else If GetKeyState(“Shift”, “P”)
Send +1
Else
Send 1
}
Return

PressKey2:
If toggle2
{
toggle1 := 0
If GetKeyState(“Control”, “P”) && GetKeyState(“Shift”)
Send +^2
Else If GetKeyState(“Control”, “P”)
Send ^2
Else If GetKeyState(“Shift”, “P”)
Send +2
Else
Send 2
}
Return

#IfWinActive

Hey eldorann,

thank you very much for your reply. I copied your script 1:1 to my AHK and it runs so far, but it seems like my GSE macros don’t use the shift or STRG modifiers when your macro is toggled on and I use a modifier. Any idea why? I want to use F and Q instead of 1 and 2 buttons, what parts in your macro would I have to edit?

Sincerly

Daniel

To use the F and Q buttons, you would replace all places I write “1” or “2” with your desired keys of F and Q.

$*F::toggleF := !toggleF
$*Q::toggleQ:= !toggleQ

The names are just a reminder. Writing “Toggle123ABC” instead of “ToggleF” is just confusing.

Example:

If GetKeyState(“Control”, “P”) && GetKeyState(“Shift”)
Send +^F (Or “Send +^Q”)

HI eldorann,

ot looks now like this:

#IfWinActive World of Warcraft

togglef := 0
toggleq := 0

SetTimer, PressKeyf, 50
SetTimer, PressKeyq, 50

$*f::togglef := !togglef
$*q::toggleq := !toggleq

PressKeyf:
If togglef
{
toggleq := 0
If GetKeyState(“Control”, “P”) && GetKeyState(“Shift”)
Send +^f
Else If GetKeyState(“Control”, “P”)
Send ^f
Else If GetKeyState(“Shift”, “P”)
Send +f
Else
Send f
}
Return

PressKeyq:
If toggleq
{
togglef := 0
If GetKeyState(“Control”, “P”) && GetKeyState(“Shift”)
Send +^q
Else If GetKeyState(“Control”, “P”)
Send ^q
Else If GetKeyState(“Shift”, “P”)
Send +q
Else
Send q
}
Return

#IfWinActive

The modifiers Shift and STRG seem to be ingnored by my macro. I am currently testing fire mage macros where Pyroblast is on Shift for example. While the macro is toggled on the action linked to shift is not fired off. Any idea why this can be?

BTW: thanks a lot, works perfectly with F and Q now. Keep healthy.

I submitted a question on my code to the AutoHotKey forum on Reddit. Switching spam keys (pressing 2 while spamming 1 or vice versa) was slow.

My new code is:

toggle1 := 0
toggle2 := 0

SetTimer, PressKey1, 100
SetTimer, PressKey2, 100

$*1::
If (toggle1 := !toggle1)
	Gosub PressKey1
Return
$*2::
If (toggle2 := !toggle2)
	Gosub PressKey2
Return

The PressKey routines remain the same. Only the key press activators are different.

Now though, it switched instantly when switching spam keys. (1 to 2 or 2 to 1. My code was starting to be slow.)

Watch Reruns of WoW Lazy Macros Creator (Lutechi) Live @ 10PM EST