key-spam-script
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. ; Ensures a consistent starting directory. SetWorkingDir %A_ScriptDir% #SingleInstance force ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Config, feel free to edit ; The delay between keypresses Delay = 300 ; The keys pressed by the script, looped in this order KeyOrder = 1 2 3 1 2 4 ; The keys that override script, while pressed, spam is halted KeyOverride = q w e r t NumpadAdd Shift ; Do this once at the beginning ActionStart() { SendInput {NumPad0 down} } ; Do this once when keyspam is cancelled ActionEnd() { SendInput {NumPad0 up} } ; The key that ends the script KeyEnd = Down ; Start the script. ! is alt. $!Down:: KeySpam() return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Code, do not touch ; This function spams the keys defined KeySpam() { ActionStart() ; Use the variables in a function, sigh global Delay global KeyEnd global KeyOrder global KeyOverride StringSplit, KeyOrderArray, KeyOrder, %A_space% StringSplit, KeyOverrideArray, KeyOverride, %A_space% ; Divide the delay to 5 parts for shorter check intervals Num := 5 Realdelay := Delay / Num index = 0 ; The main loop, one key pressed per loop loop { ; Defines if the next key-spam is delayed KeyDelayed := 0 ; Check whether priority keys are in use loop %Num% { GetKeystate, Keypres, %KeyEnd% if (KeyPres = "D") { ActionEnd() return } loop %KeyOverrideArray0% { tmpkey := KeyOverrideArray%A_index% GetKeystate, KeyPres, %tmpkey% if (KeyPres = "D") { KeyDelayed := 1 ; Send <%tmpkey%> Break } } Sleep Realdelay } ; Spam the next key if priority keys are not in use if (KeyDelayed = 0) { index := index+1 if (index > KeyOrderArray0) { index := 1 } key := KeyOrderArray%index% Send %key% } } }
key-spam-script.txt · Last modified: 2014-04-06 22:22 by era