Auto Hot Key Tutorial

Download: https://autohotkey.com/
right click desktop
select new and find ahk script in the list
open it with a text editor :https://notepad-plus-plus.org/
paste this


#MaxThreadsPerHotkey 3

numpad5::
Toggle := !Toggle
Loop
{
	If (!Toggle)
		Break
	Send 1
	Sleep 83 ; Make this number higher for slower clicks, lower for faster.
}
Return

on the “numpad5” line you can change it with https://autohotkey.com/docs/KeyList.htm
The “send 1” line is where your spell will fire so in this case it spams the number 1

Good script papapancake1 :slight_smile:

Can you add shift, ctrl and alt keys to this script?

thx in advance

I keep wondering, though, isn’t AHK against the ToS?

Keep wondering… but nope.

That’s great :slight_smile: Been on the fence about it for a long time, but didn’t want to get banned :stuck_out_tongue:

Using it, if you have no other means of repeated key pressing is fine, if you use it for 1 button press = 1 action.

The gray area is where you use 1 button press for multiple actions like pressing 1-2-3 at intervals.
More so when you start scripting AHK to play for you and move your mouse pointers etc to X,Y co-ords etc etc etc.

But for the basic 1 button press it’s absolutely fine.

There are other programs like AHK which do the same job, less hassle etc like Punchkey.
Using a hardware option like mouse/keyboard is better

Very nice, thanks for clarifying :slight_smile:
I’ve never really touched my peripherals’ software ( using a Razer Blackwidow, because GF said it was the best thing ever). Guess I should look into that.

Synapse is easy to set up and would work better for you than AHK.
AHK has other issues too when you spam, like locking up movment etc because it also sends actions to what is called a key queue and will flood it regardless of what you set your delays to.
Add in some movement to this and it’s often ignored and vice versa… becomes frustrating.

Doesn’t happen on hardware options. Not sure if Punchkey has the same issues.
AHK is just mentioned more because it’s popular and people share their scripts :stuck_out_tongue:

Just Download Punchkey, It does Exacty what your looking for…
https://punchkey.weebly.com/
https://www.facebook.com/PunchKeyPunchMouse-625527737594634/

[quote quote=54867]Download: https://autohotkey.com/ right click desktop select new and find ahk script in the list open it with a text editor :https://notepad-plus-plus.org/ paste this

<table class="crayon-table"><tbody><tr class="crayon-row"><td class="crayon-nums " data-settings="show">
1
2
3
4
5
6
7
8
9
10
11
12
13
14
</td><td class="crayon-code">
<span class="crayon-o">#</span><span class="crayon-i">MaxThreadsPerHotkey</span><span class="crayon-h"> </span><span class="crayon-cn">3</span>
<span class="crayon-v">numpad5</span><span class="crayon-o">::</span>
<span class="crayon-v">Toggle</span><span class="crayon-h"> </span><span class="crayon-o">:</span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-o">!</span><span class="crayon-e">Toggle</span>
<span class="crayon-e">Loop</span>
<span class="crayon-sy">{</span>
<span class="crayon-h"> </span><span class="crayon-st">If</span><span class="crayon-h"> </span><span class="crayon-sy">(</span><span class="crayon-o">!</span><span class="crayon-v">Toggle</span><span class="crayon-sy">)</span>
<span class="crayon-h"> </span><span class="crayon-st">Break</span>
<span class="crayon-h"> </span><span class="crayon-i">Send</span><span class="crayon-h"> </span><span class="crayon-cn">1</span>
<span class="crayon-h"> </span><span class="crayon-i">Sleep</span><span class="crayon-h"> </span><span class="crayon-cn">83</span><span class="crayon-h"> </span><span class="crayon-sy">;</span><span class="crayon-h"> </span><span class="crayon-e">Make </span><span class="crayon-r">this</span><span class="crayon-h"> </span><span class="crayon-e">number </span><span class="crayon-e">higher </span><span class="crayon-st">for</span><span class="crayon-h"> </span><span class="crayon-e">slower </span><span class="crayon-v">clicks</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-e">lower </span><span class="crayon-st">for</span><span class="crayon-h"> </span><span class="crayon-v">faster</span><span class="crayon-sy">.</span>
<span class="crayon-sy">}</span>
<span class="crayon-st">Return</span>
</td></tr></tbody></table>
on the “numpad5” line you can change it with https://autohotkey.com/docs/KeyList.htm The “send 1” line is where your spell will fire so in this case it spams the number 1 [/quote]

This is a toggle right once u click it u dont need to click it again it will keep repeating… how can i change this exact script but to use key press? Regards

[quote quote=54867]Download: https://autohotkey.com/ right click desktop select new and find ahk script in the list open it with a text editor :https://notepad-plus-plus.org/ paste this

<table class="crayon-table"><tbody><tr class="crayon-row"><td class="crayon-nums " data-settings="show">
1
2
3
4
5
6
7
8
9
10
11
12
13
14
</td><td class="crayon-code">
<span class="crayon-o">#</span><span class="crayon-i">MaxThreadsPerHotkey</span><span class="crayon-h"> </span><span class="crayon-cn">3</span>
<span class="crayon-v">numpad5</span><span class="crayon-o">::</span>
<span class="crayon-v">Toggle</span><span class="crayon-h"> </span><span class="crayon-o">:</span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-o">!</span><span class="crayon-e">Toggle</span>
<span class="crayon-e">Loop</span>
<span class="crayon-sy">{</span>
<span class="crayon-h"> </span><span class="crayon-st">If</span><span class="crayon-h"> </span><span class="crayon-sy">(</span><span class="crayon-o">!</span><span class="crayon-v">Toggle</span><span class="crayon-sy">)</span>
<span class="crayon-h"> </span><span class="crayon-st">Break</span>
<span class="crayon-h"> </span><span class="crayon-i">Send</span><span class="crayon-h"> </span><span class="crayon-cn">1</span>
<span class="crayon-h"> </span><span class="crayon-i">Sleep</span><span class="crayon-h"> </span><span class="crayon-cn">83</span><span class="crayon-h"> </span><span class="crayon-sy">;</span><span class="crayon-h"> </span><span class="crayon-e">Make </span><span class="crayon-r">this</span><span class="crayon-h"> </span><span class="crayon-e">number </span><span class="crayon-e">higher </span><span class="crayon-st">for</span><span class="crayon-h"> </span><span class="crayon-e">slower </span><span class="crayon-v">clicks</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-e">lower </span><span class="crayon-st">for</span><span class="crayon-h"> </span><span class="crayon-v">faster</span><span class="crayon-sy">.</span>
<span class="crayon-sy">}</span>
<span class="crayon-st">Return</span>
</td></tr></tbody></table>
on the “numpad5” line you can change it with https://autohotkey.com/docs/KeyList.htm The “send 1” line is where your spell will fire so in this case it spams the number 1[/quote]

This is a toggle right once u click it u dont need to click it again it will keep repeating… how can i change this exact script but to use key press? Regards

this works good but it wont stop lol, i press the button and it just keeps going on its own.

Here is a AHK script I came up with a while back that does exactly what the original poster was looking for. It’s scripted for 2 keys, “-” and “=”, but the code was written so you’d only have to modify 2 lines to make it work for whichever 2 keys you want to toggle spamming on and off.

;   Title: WoWscripts - Spamming macro hotkeys that Toggle themselves ON and OFF
;  author: David J Rosenheim
;    date: July 16, 2016
; purpose: Reposition and resize World of Warcraft window as soon as it's opened
;           then setup multiple hotkeys capable of toggling themselves on and off.

/* ChangeLog
	
	0.9.0.1 Beta
	Date: 05/15/20  7:09 PM
	
	- removed WinMaximize and chgd back to WinMove as maximized WoW windows were causing issues when alt-tabbing to other windows
	- script defines 2 winProcesses - 1st for World of Warcraft Retail, 2nd for World of Warcraft Classic
	- created _winGroup and modified script so that hot keys are context-sensitive to only windows in the Group
	
	0.8.0.1  Beta
	Date: 9/03/19  1:09:10 PM
	
	- Changed WinMove to WinMaximize as game window extends beyond left/right side of screen when full height
	
	0.8.0.0  Beta
	Date: 9/09/18  3:36:41 PM
	
	- Added logic that detects if the current Hotkey is the same as previous hotkey
	- Changed new behaviour that causing currently running spamming loop to switch to a new hotkey character without toggling OFF first.
	- Added _swapHotKeys boolen variable to allow user to turn new "swapping hotkey character" behaviour ON or OFF.
	
	0.7.1.0  Beta
	Date: 9/09/18  12:54:14 PM
	
	- small number of updates to some comments to make logic more clear
	
	0.7.0.0  Beta
	Date: 8/11/16  11:26:26 PM
	
	- Moved main code to SpamHotKey label so that multiple hotkeys can be processed using the same code
	- changed method of defining hotkeys from double-colon to Hotkey command
	- changed method of specifing context-sensitivity for hotkeys from "#If WinActive(" to "Hotkey, IfWinActive"
	- #MaxThreadsPerHotkey is now 2 instead of 1 and is only defined under the SpamHotKey label
	- Now parsing A_ThisHotkey to get the keystroke for the SendInput command.  Parsing removes "$", if first character.
		Since a hotkey's modifiers (ctrl,alt,shift) are included in its name, parsing A_ThisHotkey ensures that the
		modifiers will be included as part of the keystroke sent by the SendInput command.
	- Suspend hotkey is now working correctly
	- all hotkeys (including Suspend hotkey) are correctly context-sensitive and only working in the _winProcess window. 
*/

#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%  ; Ensure a consistent working directory by making script unconditionally use its own folder.

_winProcess  := "ahk_exe Wow.exe"  			; change this to match your 1st window title, class or process
_winProcess2 := "ahk_exe WowClassic.exe"  ; change this to match your 2nd window title, class or process
_hKey1  := "-"   ; change this to your first hotkey key/char
_hKey2  := "="   ; change this to your second hotkey key/char
_KeepHotKeyRunning := false   ; initial assignment is false

_swapHotKeys = true  ; true  = Allow running hotkey loop to switch to new hotkey character.  Press same hotkey to toggle off.
							; false = Pressing any hotkey toggles OFF current spamming hotkey character.

GroupAdd, _winGroup, %_winProcess%	; Create Group and add 1st process
GroupAdd, _winGroup, %_winProcess2%	; Add 2nd process to same Group	

; Wait until any window in _winGroup is opened, then maximize it
WinWaitActive, ahk_group _winGroup
WinMove, ,, -7, -9   , 1933, 1049   ; change x, y, width, height to match your preference

Hotkey, IfWinActive, ahk_group _winGroup ; makes all hotkeys that follow context-sensitive (i.e. only work in _winGroup windows)
Hotkey, % "$" . _hKey1, SpamHotKey     ; rapidfire hotkey 1
Hotkey, % "$" . _hKey2, SpamHotKey     ; rapidfire hotkey 2
Hotkey, ^!s           , Suspend_hKeys  ; Assign the toggle-suspend function to hotkey Ctrl+Alt+S.
Hotkey, IfWinActive

return

Suspend_hKeys:
	Suspend     ; toggles hotkey suspension on/off
	return

SpamHotKey: 
	#MaxThreadsPerHotkey 2         ; this directive CANNOT be 1 and probably shouldn't be more than 2
	_keyStroke := A_ThisHotkey

	If  SubStr(_keyStroke,1,1) = "$" 
		_keyStroke := SubStr(_keyStroke,2)   ; trim the "$" from the beginning of hotkey name

	; When hotkey loop is already running...
	if _KeepHotKeyRunning { ; This means an underlying thread is already running the loop below.
	  ; if hotkey is not same as previous hotkey, allow loop to keep running using new hotkey's character
	  If (_swapHotKeys and _keyStroke != _prevKeyStroke)
			_prevKeyStroke := _keyStroke
	  else  ; hotkey just pressed is same as previous hotkey
			_KeepHotKeyRunning := false  ; Signal that thread's loop to stop.
	  return  ; End this thread so that the one underneath will resume and see the change made above.
	}
	
	; ... Otherwise,
	; When hotkey is toggled ON, following LOOP sends that hotkey's character repeatedly until hotkey is toggled off
	_KeepHotKeyRunning := true
	_prevKeyStroke := _keyStroke

	Loop { ; The next two lines are the action you want to repeat (update them to suit your preferences):
		sendinput, %_keyStroke%  ; spams the hotkey character until it's toggled off
		sleep 30
		; But leave the rest below unchanged.
		if not _KeepHotKeyRunning  ; The user signaled the loop to stop by pressing myHK key again.
			break  ; Break out of this loop.
	}
	
	_KeepHotKeyRunning := false  ; Reset in preparation for the next press of this hotkey.
	return

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