New AHK script to easy change key and ms speed :)

Hello there.
I’ve been dabbeling a bit in the AHK scripting and made a script that you toggle on and off with F9 (You can change this easy aswell) and you just need to edit two things for speed and keybind :slight_smile:
Default keybind is Q (My preffered key) and speed is 50ms.
As there are alot of macro’s that require diffrent speeds and some have 1x for Single target and 1x for AoE you just simply make 2x AHK scripts and run them at the same time with diffrent binds (Both the press key and the toggle key need to be changed or it conflicts) :slight_smile:
Example:
Single Target on Q and AoE on E, you make 1 AHK with this script and have it on Q with F9 as toggle on/off, then another script with E as the keybind and F10 as toggle on/off. Start them both then go ingame, press F9 and F10 and they should be started.
This script also only works in the world of warcraft window, so if you tab out to type something it will not work outside of the game.
I find the toggle helpful if I need to type in the party so I dont spam the letter used. So many times I’ve typed with E as keybind and it suddenly goes “Doneeeee” :stuck_out_tongue:

Script for using Q with F9 as Toggle on/off:

; Set the toggle variable to off
toggle := 0
keybind := "q"
delay := 50

; Set the send mode to input (may not be necessary depending on your system)
SendMode Input

; Define the function to send the keystroke
SendKey:
    IfWinActive, World of Warcraft
    {
        Loop {
            if not GetKeyState(keybind, "P") {
                break
            }
            if GetKeyState("LCtrl", "P") {
                SendInput ^{%keybind%}
            } else if GetKeyState("LShift", "P") {
                SendInput +{%keybind%}
            } else if GetKeyState("LAlt", "P") {
                SendInput !{%keybind%}
            } else {
                SendInput {%keybind%}
            }
            sleep delay
        }
    }
return

#IfWinActive, World of Warcraft ; Only run if window 'World of Warcraft' is active
$F9::
    toggle := !toggle
    if (toggle) {
        SetTimer, SendKey, %delay%
    } else {
        SetTimer, SendKey, Off
    }
return
#IfWinActive

; If World of Warcraft is not running, turn off the script
#IfWinNotExist, World of Warcraft
    SetTimer, SendKey, Off
    toggle := 0
#IfWinActive

Script for E using F10 as toggle on/off:

; Set the toggle variable to off
toggle := 0
keybind := "e"
delay := 50

; Set the send mode to input (may not be necessary depending on your system)
SendMode Input

; Define the function to send the keystroke
SendKey:
    IfWinActive, World of Warcraft
    {
        Loop {
            if not GetKeyState(keybind, "P") {
                break
            }
            if GetKeyState("LCtrl", "P") {
                SendInput ^{%keybind%}
            } else if GetKeyState("LShift", "P") {
                SendInput +{%keybind%}
            } else if GetKeyState("LAlt", "P") {
                SendInput !{%keybind%}
            } else {
                SendInput {%keybind%}
            }
            sleep delay
        }
    }
return

#IfWinActive, World of Warcraft ; Only run if window 'World of Warcraft' is active
$F10::
    toggle := !toggle
    if (toggle) {
        SetTimer, SendKey, %delay%
    } else {
        SetTimer, SendKey, Off
    }
return
#IfWinActive

; If World of Warcraft is not running, turn off the script
#IfWinNotExist, World of Warcraft
    SetTimer, SendKey, Off
    toggle := 0
#IfWinActive

Any issues please do tell :slight_smile:

3 Likes