Updated: Key Spam With Mods - Smoother Code

This is an updated script. In addition to clearer code, it adds a random sleep.

Random sleep helps to avoid detection of bot spams. Varying between 25 and 75 milliseconds mimics a frantic finger spamming. A constant key press might set off a bot detector.

This is not intended to promote botting but rather is an artistic decision. Any side effects are unintended.

To return to a constant interval, simply remove the code

Random slp,25,75
Sleep slp

and replace it with

Sleep 100 (Or whatever you wish)

#ifWinActive World of Warcraft ; Only run if window ‘World of Warcraft’ is active

SetTimer, PressKey1, 10
SetTimer, PressKey2, 10

$1:: ; If 1 is pressed
$^1:: ; If 1+control is pressed
$+1:: ; If 1+shift is pressed
$!1:: ; If 1+alt is pressed
$+^1:: ; If 1+shift+control is pressed.
If (toggle1 := !toggle1)
{
Random slp,25,75
Sleep slp
Gosub PressKey1
}
Return

$2:: ; If 2 is pressed
$^2:: ; If 2+control is pressed
$+2:: ; If 2+shift is pressed
$!2:: ; If 2+alt is pressed
$+^2:: ; If 2+shift+control is pressed.
If (toggle2 := !toggle2)
{
Random slp,25,75
Sleep slp
Gosub PressKey2
}
Return

PressKey1:
If toggle1
{
toggle2 = 0
if GetKeyState(“LCtrl”, “P”) && GetKeyState(“LShift”,“P”) ; If left control is pressed then send control+shift+1
Send ^+1
else if GetKeyState(“LCtrl”, “P”) ; If left control is pressed then send control+1
Send ^1
else if GetKeyState(“LShift”, “P”) ; If left shift is pressed then send shift+1
Send +1
else if GetKeyState(“LAlt”, “P”) ; If left alt is pressed then send alt+1
Send !1
else
Send 1 ; If 1 is pressed with no other modifiers send 1
return
}

PressKey2:
If toggle2
{
toggle1 = 0
if GetKeyState(“LCtrl”, “P”) && GetKeyState(“LShift”,“P”) ; If left control is pressed then send control+shift+1
Send ^+2
else if GetKeyState(“LCtrl”, “P”) ; If left control is pressed then send control+2
Send ^2
else if GetKeyState(“LShift”, “P”) ; If left shift is pressed then send shift+2
Send +2
else if GetKeyState(“LAlt”, “P”) ; If left alt is pressed then send alt+2
Send 2
else
Send 2 ; If 2 is pressed with no other modifiers send 2
return
}