AHK Script/question about delays

I had a fellow on the AHK forums perfect a script for me. I will provide it below if anyone finds the same need for it. In a nutshell, I have physical issues and find that I can raid and even do general play better with the Razer Orbweaver (a game pad). The script basically toggles the 3 keys I have bound to Num1, Num2 and Num3. Num0 toggles all active keys off. It works well for me as far as basic rotations (I have Num1 as my aoe heals, Num2 as my minor heals and Num3 as my major heals macros). However, I have been reading about setting delays for AHK or Razer. Is this possible, or do I even need to do that, if I’m using AHK/Razer as I do? If so, WHERE do I set the delay? I’m not even seeing that option in Synapse unless I record my own macro, not sure that’s wise setting a recorded macro for a macro in game?

I present the script in order that someone might try it and see if it works as is or can see what I mean, and if I even need a delay added anywhere:


#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
toggles := [0,0,0] ;create an array with 3 toggle states for numpad1/2/3 default to off (0)

numpad0::toggles := [0,0,0]  ;kill all toggles

numpad1::
toggles[1] := !toggles[1] ;invert toggle state 0>1>0>1 etc
if (toggles[1]) {
	settimer, combat,1 ;having a goto here causes numpad1 not to toggle off idk why
} else {
	;toggles := [0,0,0] ;reset all toggle states  ;uncomment this if you want numpad1 to still reset all toggles
}
return

numpad2::
toggles[2] := !toggles[2]
if (toggles[2])
	settimer,combat,1
return

numpad3::
toggles[3] := !toggles[3]
if (toggles[3])
	settimer,combat,1
return

combat:
settimer,combat,off
while(toggles[1] or toggles[2] or toggles[3]) { ;while any toggles are active
	if (toggles[1]) {
		ControlSend,,1,World of Warcraft
		sleep 50
	}
	if (toggles[2]) { ;if numpad2 toggle == true
		ControlSend,,2,World of Warcraft
		sleep 100
	}
	if (toggles[3]) {
		ControlSend,,3,World of Warcraft
		sleep 100
	}
}
return

f9::reload

The delay is already presented in the script.
In this case it’s called Sleep.

1 is sleep 50 which is the same as delay 50ms
2 and 3 you have sleep 100 which is 100ms delay

Now…

If you are running your orb weaver then you don’t need to run AHK… it’s pointless as they do the same thing.
The advantage is that the orb weaver is hardware based while AHK are for those who don’t have this kind of functionality on their current keyboard/mouse.

You mention that you don’t think it’s wise to create a macro for an ingame macro, but this is exactly what you do for these macros, you’re creating a macro which repeatedly presses a key for you at a set period to initiate an ingame macro.

In the orb weaver, you record a keypress and set the delay and then assign it to an orb weaver key

Example:

Record Macro
hit Key 1 down
Key 1 Release
Delay 100

assign that to a key on the orb weaver and then press that key ingame which will then continously press 1 for you.

This is the same feature as you’re asking for in AHK so it’s best running only 1 or the other, preferably the orb weaver as AHK is software based and prone to more issues like key queues and lag etc.

Thank you Cym!! I had wondered if I was duplicating my efforts :slight_smile: I had the ahk script made before I had the orbweaver, so thought “ehhh why not do both?” hehe
I am so happy now! I will go set those macros asap!

However, I will leave the script up for anyone else who might not have the functionality with Razer and might benefit from it

Update: I could hug you for this, Cym. I am still sorta new’ish to the Orbweaver so wasn’t that great at setting it up other than through AHK. When that AHK script was “on” it interfered with my PTT on Discord during combat, like if I was trying to heal and make callouts and such in raid.

This is so much easier! The Orbweaver and the script just did not seem to play well together, and now i get why. Thanks again!