Potentially Useful AHK Script

Hello, not sure if this is the best place but couldn’t see anywhere else it would really fit.

I have spent a while tinkering with one of the AHK scripts that Hadronox has kindly pinned in the AHK section of the discord and thought that someone else might find use for it.

Changes made are to have a script control key that will enable or disable the whole script, disabling all running hotkeys and stopping any hotkeys from being activated until the script is turned on again.

I have also added a third hotkey allong side the two hotkes, this is setup to allow you to keep the key spammer going while also pressing another key. I have been using this as an interrupt and it seems to be working just as intented allowing me to cast an interrupt without turning the spam off.

I have also added more on screen displays to provide information as to if the script is On or Off to complement the on screen display in the original macro that tells you if you are running hotkey 1 or 2.

The script will send modifier keys such as Shift and Control if pressed and will also disable one hotkey if you press another, for example if you have 1 toggled and then press 2 hotkey 1 will toggle off and only hotkey 2 will run, pressing 2 again will toggle 2 off and neither key will be running.

This is by no means a perfect AHK script and im sure someone will be able to improve it further but its been working well for me and might work well for someone else.

Obviously feel free to change or remove whatever you want, I know that some people might not like the on screen displays showing you if the script or keys are active but I like it.

;; ############################
;; INFO
;; ############################

; ##################################################################
; Credit to Hadronox for coming up with some really useful scripts. 
; This is an updated version of his two button configurble script.
; It has had a script control key added to it that allows you to 
; enale or disable all hotkeys and will show the status of the script.
; I have also added another hotkey that will send without disabling 
; any currently running hotkeys, I have been using this for interrupts.
; ##################################################################

;; for a list of AHK Keys: https://autohotkey.com/docs/KeyList.htm 44

;; PROGRESS WINDOW: https://autohotkey.com/docs/commands/Progress.htm 24
;; Progress, M B1 X1325 Y675 C1 W75 ZH-5 ZX0 ZY0 FM0 FS25 WM1 WS600 CT40FF06 CW000000, ON1,ON1,Verdana
; M: movable window / B: No border / B1: thin border, no title bar / B2: thick border.
; Xn/Yn coord upper left corner / Cxy: centered sub/main text / Wn: width client area.
; ZHn: window height/thickness / ZXn: left/right margin / ZYn: top/bottom margin.
; FMn: main font size, 0=10 / FSn: sub font size, 0=8.
; WMn: main font weight / WSn: sub font weight, 1-1000, 600=semi bold, 700=bold, 400=normal.
; CTn: color text / CWn: color background, 16 primary HTML color names or a 6-digit RGB hex.

;; Key modifiers Info
; < & > denote if the left or right modifier will be pressed, eg <! is left shift
; 
; + = Shift
; ^ = Ctrl
; ! = Alt


;; #################################
;; AUTO EXEC
;; #################################

#NoEnv
SetWorkingDir %A_ScriptDir%
SendMode Input
#SingleInstance Force
#MaxThreadsPerHotkey 2
#IfWinActive World of Warcraft

;; #################################
;; CONFIG
;; #################################

;; ------------------
;; Script Control key
;; ------------------

;;Key to enable or disable other hotkeys 
ScriptKey = F4

;; ------------------
;; Toggle Key A 
;; ------------------

;; Lable, eg ST, AOE, etc
;; This will be displayed on the screen when this key is active.
LabelA = ST

;; Set the key you want to press to start spam.
KeyToPressA = F1

;; Delay between key press
DelayA := 100

;; Key to spam
KeyToSpamA = 0

;; ------------------
;; Toggle Key B 
;; ------------------

;; Lable, eg ST, AOE, etc
;; This will be displayed on the screen when this key is active.
LabelB = AOE

;; Set the key you want to press to start spam.
KeyToPressB = F2

;; Delay between key press
DelayB := 100

;; Key to spam
KeyToSpamB = =

;; ------------------------------------
;; Toggle Key I (Interrupt Specific)
;; ------------------------------------

;; Lable, eg ST, AOE, etc
;; This will be displayed on the screen when this key is active.
LabelI = INT

;; Set the key you want to press to start spam.
KeyToPressI = R

;; Delay between key press
DelayI := 100

;; Key to spam 
KeyToSpamI = 5

;;Mod
ModKey = <+

;; #################################
;; MAIN
;; #################################

ToggleA := 0
ToggleB := 0
ToggleI := 0
ToggleScript := 0

Hotkey, $%ScriptKey%, ScriptToggle
Hotkey, $%KeyToPressA%, AToggle
Hotkey, $%KeyToPressB%, BToggle
Hotkey, $%KeyToPressI%, InterruptPress


if (ToggleScript = 0){
	Progress, M B1 X5 Y15 C1 W75 ZH-5 ZX0 ZY0 FM0 FS25 WM1 WS600 CT40FF06 CW000000, OFF, , ,Verdana		
}
return

ScriptToggle:
ToggleScript := !ToggleScript
if(ToggleScript = 0)
{
	Gosub ResetScript
}else {
	Progress, M B1 X5 Y15 C1 W75 ZH-5 ZX0 ZY0 FM0 FS25 WM1 WS600 CT40FF06 CW000000, ON, , ,Verdana
}
return

;; ------------------

AToggle:
ToggleA := !ToggleA
if (ToggleScript = 0){
	Gosub ResetScript
}
else if (ToggleA = 1 and ToggleScript = 1)
{
	Gosub PressKeyA
	
}else if (ToggleA = 0 and ToggleScript = 1){
	Gosub Reset
}
Return

;; ------------------

BToggle:
ToggleB := !ToggleB
if (ToggleScript = 0){
	Gosub ResetScript
}
else if (ToggleB = 1 and ToggleScript = 1)
{
	Gosub PressKeyB
}
else if (ToggleB = 0 and ToggleScript = 1)
{
	Gosub Reset
}
return

;; ------------------

InterruptPress:
if (ToggleScript = 0){
	Send, {Blind}r
	Gosub ResetScript
}
else if(ToggleScript = 1)
{
	Gosub InterruptKey
}
return

;; ------------------
;; ------------------

PressKeyA:
ToggleB := 0

SetTimer, SpamKeyB, Off
SetTimer, SpamKeyA, %DelayA%

Progress, M B1 X1325 Y675 C1 W75 ZH-5 ZX0 ZY0 FM0 FS25 WM1 WS600 CT40FF06 CW000000, %LabelA%, , ,Verdana

return

;; ------------------

PressKeyB:
ToggleA := 0

SetTimer, SpamKeyA, Off
SetTimer, SpamKeyB, %DelayB%

Progress, M B1 X1325 Y675 C1 W75 ZH-5 ZX0 ZY0 FM0 FS25 WM1 WS600 CT40FF06 CW000000, %LabelB%, , ,Verdana

return

;; ------------------

Reset:
ToggleA := 0	
ToggleB := 0

SetTimer, SpamKeyA, Off
SetTimer, SpamKeyB, Off
SetTimer, InterruptKey, Off

Progress, M B1 X5 Y15 C1 W75 ZH-5 ZX0 ZY0 FM0 FS25 WM1 WS600 CT40FF06 CW000000, ON, , ,Verdana

return

;; ------------------

ResetScript:

ToggleScript := 0
ToggleA := 0	
ToggleB := 0

SetTimer, SpamKeyA, Off
SetTimer, SpamKeyB, Off
SetTimer, InterruptKey, Off

Progress, M B1 X5 Y15 C1 W75 ZH-5 ZX0 ZY0 FM0 FS25 WM1 WS600 CT40FF06 CW000000, OFF, , ,Verdana

return


;; ------------------
;; ------------------

;; blind mode to send modifiers
SpamKeyA:
Send, {Blind}{%KeyToSpamA%}
return

;; ------------------

;; blind mode to send modifiers
SpamKeyB:
Send, {Blind}{%KeyToSpamB%}
return

;; ------------------

;; blind mode to send modifiers


InterruptKey:
Send, %ModKey%{%KeyToSpamI%}
return


;; #################################
;; CONTROLS
;; #################################

^PgDn::Suspend ;; Ctrl + PageDown to suspend script (if you want to chat)
^PgUp::Reload ;; Ctrl + PageUP to reload script
^End::ExitApp ;; Ctrl + End to terminate script
1 Like