[12/29/2021 UPDATE] [Script] Rapid Key Presser for World of Warcraft or other MMOs!

Post gaming related scripts
Vphrism
Posts: 2
Joined: 10 Nov 2020, 20:39

[12/29/2021 UPDATE] [Script] Rapid Key Presser for World of Warcraft or other MMOs!

Post by Vphrism » 10 Nov 2020, 21:20

AHK Rapid Key Presser for World of Warcraft or other MMOs!


What does this script do?
Repeat key presses when held down so you don't have to repeatedly press your keys to activate your abilities when it's almost time to press them.

Why should you use this script?
Very lazy at pressing keys
May prevent finger pain
Improves gameplay performance/experience

What numbers and letters does it repeat?
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
q, e, r, t, f, g, z, x, c, v

All modifier keys in combination with the numbers and letters above!
Example: Shift + 1, Ctrl + 1, Alt + 1

To suspend/pause the script: F12
To reload the script: Ctrl + F12
To close the script: End

Key presses are set at 20 milliseconds
Change it to a different number if you wish!
Higher = Slower
Lower = Faster

Why not W, A, S, or D?
These are your basic movement keys, but feel free to add/edit any keys you want.

I highly recommend using Notepad++ and set it to C++ language or whichever you prefer for an easier viewing experience of the script.

Gaming MMO Mouse highly recommended!

I'm very new at coding and scripting in general so if anyone has any suggestions on how to condense more efficient scripts. I welcome advice!

12/29/2021 UPDATE
Hello! It's been a long while since I've posted this, so I came to revise, update, and condensed the code for an easier and simpler experience.

Reduced lines of code from 509 to 388

Code: Select all


#ifWinActive World of Warcraft ;Checks if the World of Warcraft window is opened
#MaxThreadsPerHotkey 2 ;Used to control how many "instances" of a given hotkey or hotstring subroutine are allowed to exist simultaneously

SendTime:= 20 ; Time in milliseconds to repeat key press
$0:: ; Number 0
$^0:: ; Ctrl + 0
$+0:: ; Shift + 0
$!0:: ; Alt + 0
Loop ;Begins the code for looping/repeats
{ ;Begging code structure
if not GetKeyState("0", "P") ;Checks to see if a key is pressed down
break ; Terminates the Loop
if GetKeyState("Ctrl", "P") ;Checks if Ctrl is pressed
Send ^0 ;Sends Ctrl + 0
else if GetKeyState("Shift", "P") ;Checks if Shift is pressed
Send +0 ;Sends Shift + 0
else if GetKeyState("Alt", "P") ;Checks if Alt is pressed
Send !1 ;Sends Alt + 0
else ;Checks if Number 1 is pressed
Send 1 ;Sends Number 1
sleep %SendTime% ;Sends whatever sendTime value is set as
} ;Ending code structure
return

$1::
$^1::
$+1::
$!1::
Loop{
if not GetKeyState("1", "P")
break
if GetKeyState("Ctrl", "P")
Send ^1
else if GetKeyState("Shift", "P")
Send +1
else if GetKeyState("Alt", "P")
Send !1
else
Send 1
sleep %SendTime%
}
return

$2::
$^2::
$+2::
$!2::
Loop{
if not GetKeyState("2", "P")
break
if GetKeyState("Ctrl", "P")
Send ^2
else if GetKeyState("Shift", "P")
Send +2
else if GetKeyState("Alt", "P")
Send !2
else
Send 2
sleep %SendTime%
}
return

$3::
$^3::
$+3::
$!3::
Loop{
if not GetKeyState("3", "P")
break
if GetKeyState("Ctrl", "P")
Send ^3
else if GetKeyState("Shift", "P")
Send +3
else if GetKeyState("Alt", "P")
Send !3
else
Send 3
sleep %SendTime%
}
return

$4::
$^4::
$+4::
$!4::
Loop{
if not GetKeyState("4", "P")
break
if GetKeyState("Ctrl", "P")
Send ^4
else if GetKeyState("Shift", "P")
Send +4
else if GetKeyState("Alt", "P")
Send !4
else
Send 4
sleep %SendTime%
}
return

$5::
$^5::
$+5::
$!5::
Loop{
if not GetKeyState("5", "P")
break
if GetKeyState("Ctrl", "P")
Send ^5
else if GetKeyState("Shift", "P")
Send +5
else if GetKeyState("Alt", "P")
Send !5
else
Send 5
sleep %SendTime%
}
return

$6::
$^6::
$+6::
$!6::
Loop{
if not GetKeyState("6", "P")
break
if GetKeyState("Ctrl", "P")
Send ^6
else if GetKeyState("Shift", "P")
Send +6
else if GetKeyState("Alt", "P")
Send !6
else
Send 6
sleep %SendTime%
}
return

$7::
$^7::
$+7::
$!7::
Loop{
if not GetKeyState("7", "P")
break
if GetKeyState("Ctrl", "P")
Send ^7
else if GetKeyState("Shift", "P")
Send +7
else if GetKeyState("Alt", "P")
Send !7
else
Send 7
sleep %SendTime%
}
return

$8::
$^8::
$+8::
$!8::
Loop{
if not GetKeyState("8", "P")
break
if GetKeyState("Ctrl", "P")
Send ^8
else if GetKeyState("Shift", "P")
Send +8
else if GetKeyState("Alt", "P")
Send !8
else
Send 8
sleep %SendTime%
}
return

$9::
$^9::
$+9::
$!9::
Loop{
if not GetKeyState("9", "P")
break
if GetKeyState("Ctrl", "P")
Send ^9
else if GetKeyState("Shift", "P")
Send +9
else if GetKeyState("Alt", "P")
Send !9
else
Send 9
sleep %SendTime%
}
return

$q::
$^q::
$+q::
$!q::
Loop{
if not GetKeyState("q", "P")
break
if GetKeyState("Ctrl", "P")
Send ^q
else if GetKeyState("Shift", "P")
Send +q
else if GetKeyState("Alt", "P")
Send !q
else
Send q
sleep %SendTime%
}
return

$e::
$^e::
$+e::
$!e::
Loop{
if not GetKeyState("e", "P")
break
if GetKeyState("Ctrl", "P")
Send ^e
else if GetKeyState("Shift", "P")
Send +e
else if GetKeyState("Alt", "P")
Send !e
else
Send e
sleep %SendTime%
}
return

$r::
$^r::
$+r::
$!r::
Loop{
if not GetKeyState("r", "P")
break
if GetKeyState("Ctrl", "P")
Send ^r
else if GetKeyState("Shift", "P")
Send +r
else if GetKeyState("Alt", "P")
Send !r
else
Send r
sleep %SendTime%
}
return

$t::
$^t::
$+t::
$!t::
Loop{
if not GetKeyState("t", "P")
break
if GetKeyState("Ctrl", "P")
Send ^t
else if GetKeyState("Shift", "P")
Send +t
else if GetKeyState("Alt", "P")
Send !t
else
Send t
sleep %SendTime%
}
return

$f::
$^f::
$+f::
$!f::
Loop{
if not GetKeyState("f", "P")
break
if GetKeyState("Ctrl", "P")
Send ^f
else if GetKeyState("Shift", "P")
Send +f
else if GetKeyState("Alt", "P")
Send !f
else
Send f
sleep %SendTime%
}
return

$g::
$^g::
$+g::
$!g::
Loop{
if not GetKeyState("g", "P")
break
if GetKeyState("Ctrl", "P")
Send ^g
else if GetKeyState("Shift", "P")
Send +g
else if GetKeyState("Alt", "P")
Send !g
else
Send g
sleep %SendTime%
}
return

$z::
$^z::
$+z::
$!z::
Loop{
if not GetKeyState("z", "P")
break
if GetKeyState("Ctrl", "P")
Send ^z
else if GetKeyState("Shift", "P")
Send +z
else if GetKeyState("Alt", "P")
Send !z
else
Send z
sleep %SendTime%
}
return

$x::
$^x::
$+x::
$!x::
Loop{
if not GetKeyState("x", "P")
break
if GetKeyState("Ctrl", "P")
Send ^x
else if GetKeyState("Shift", "P")
Send +x
else if GetKeyState("Alt", "P")
Send !x
else
Send x
sleep %SendTime%
}
return

$c::
$^c::
$+c::
$!c::
Loop{
if not GetKeyState("c", "P")
break
if GetKeyState("Ctrl", "P")
Send ^c
else if GetKeyState("Shift", "P")
Send +c
else if GetKeyState("Alt", "P")
Send !c
else
Send c
sleep %SendTime%
}
return

$v::
$^v::
$+v::
$!v::
Loop{
if not GetKeyState("v", "P")
break
if GetKeyState("vtrl", "P")
Send ^v
else if GetKeyState("Shift", "P")
Send +v
else if GetKeyState("Alt", "P")
Send !v
else
Send v
sleep %SendTime%
}
return

f12::Suspend
^f12::Reload
End::ExitApp

Last edited by Vphrism on 29 Dec 2021, 04:27, edited 1 time in total.

User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: [Script] Auto Key Presser for World of Warcraft or other MMOs

Post by Xtra » 11 Nov 2020, 01:33

Give this a try it should give you some ideas:

Code: Select all

#NoEnv
#UseHook // is necessary if the script uses the Send command to send the keys that comprise the hotkey itself
#CommentFlag // ; Change to C++ comment style
#IfWinActive World of Warcraft // Works only in World of Warcraft. You can change the name to whatever game you want
// Comment out above by putting // and a space above in front of #IfWinActive if you want this script to work everywhere!

// --------------------------------------------------------------------------------------------------------------------
// This autohotkey script loops/repeats keypresses when holding down a key. Also with modifers!

// This script loops numbers 0-9 with Shift, Ctrl, Alt modifers
// Also loops letters q, e, r, t, f, g, z, x, c, v with Shift, Ctrl, Alt modifiers

// Example: 1, Shift+1, Ctrl+1, Alt+1
// Example: q, Shift+q, Ctrl+q, Alt+q

// Below are key modifers that we put before a number or letter
// + = Shift, ^ = Ctrl, ! = Alt

// Will only do comments the first number and modifer to get an idea of what it does
// ---------------------------------------------------------------------------------------------------------------------
keyList := "0,1,2,3,4,5,6,7,8,9"                     // Numbers 0 - 9
		. ",q,e,r,t,f,g,z,x,c,v"                     // Letters q, e, r, t, f, g, z, x, c, v   
	   
Loop, Parse, keyList, CSV
{
	Hotkey, % Trim(A_LoopField), spamKey, On
	Hotkey, % "^" . Trim(A_LoopField), spamKey, On   // ^
	Hotkey, % "!" . Trim(A_LoopField), spamKey, On   // !
	Hotkey, % "+" . Trim(A_LoopField), spamKey, On   // +
}
return
// ---------------------------------------------------------------------------------------------------------------------

spamKey:
	checkKey := RegExReplace(A_ThisHotkey, "[*^!+]")
	Loop                                     // Starts the loop script below
	{
		Send % A_ThisHotkey                  // Sends and repeats the hotkey
		sleep 30                             // How fast it repeats the keypress in milliseconds
	}until not GetKeyState(checkKey, "P")    //Checks to see if hotkey is held down or not
return

+Esc::Suspend  // Suspend hotkeys
It does not handle keys that require { } when sending like {F1} - {F12} or {Space} I will leave that for you to do.
HTH

84JKBc8aEUByYe
Posts: 3
Joined: 17 Nov 2020, 12:03

Re: [Script] Auto Key Presser for World of Warcraft or other MMOs

Post by 84JKBc8aEUByYe » 17 Nov 2020, 12:07

I can't get these to work on the Shadowlands Beta Client. Have they somehow blocked this functionality in WoW's client?

EDIT: I fixed the issue. I had the beta running as Admin which prevented AHK from interacting with it. Gonna leave this for future internetizens who might have the same problem.

Bandit_Breaker
Posts: 1
Joined: 14 Feb 2021, 14:55

Re: [Script] Auto Key Presser for World of Warcraft or other MMOs

Post by Bandit_Breaker » 14 Feb 2021, 15:06

i need a key presser for q i dont know how to script it

User avatar
Grendahl
Posts: 170
Joined: 30 Sep 2013, 08:21

Re: [Script] Auto Key Presser for World of Warcraft or other MMOs

Post by Grendahl » 11 Mar 2021, 08:57

-deleted-
Last edited by Grendahl on 19 Jan 2022, 08:35, edited 1 time in total.

Vphrism
Posts: 2
Joined: 10 Nov 2020, 20:39

Re: [12/29/2021 UPDATE] [Script] Rapid Key Presser for World of Warcraft or other MMOs!

Post by Vphrism » 29 Dec 2021, 04:37

You can edit SendTime:20 to a higher or lower value for desired speed key repeats
Lower values = Faster
Higher values = Slower

Comment out #ifWinActive World of Warcraft by doing ;#ifWinActive World of Warcraft with the ; in front to comment out to have it work everywhere else on your desktop and other games.
Make sure you run the script as Administrator to fix any file permissions or privileges set on other games or programs to have it work there.

dezidashoota
Posts: 1
Joined: 22 Apr 2022, 17:59

Re: [12/29/2021 UPDATE] [Script] Rapid Key Presser for World of Warcraft or other MMOs!

Post by dezidashoota » 21 Jul 2022, 15:10

This script sometimes makes the alt key stuck & presses alt modifier keys without holding, and pressing alt fixes the problem. How can this be fixed?

Dolbaebx
Posts: 3
Joined: 02 Dec 2022, 06:38

Re: [12/29/2021 UPDATE] [Script] Rapid Key Presser for World of Warcraft or other MMOs!

Post by Dolbaebx » 02 Dec 2022, 06:54

Hey!
I know it and old topic, but mby someone could help me ?
When I try to add mouse 4 and 5 (Xbutton1, Xbutton2) it starts pressing random keys and I don't understand why maybe someone could look at what I did wrong?

Code: Select all

$Xbutton2::
$^Xbutton2::
$+Xbutton2::
$!Xbutton2::
Loop{
if not GetKeyState("Xbutton2", "P")
break
if GetKeyState("ctrl", "P")
Send ^Xbutton2 
else if GetKeyState("Shift", "P")
Send +Xbutton2 
else if GetKeyState("Alt", "P")
Send !Xbutton2 
else
Send Xbutton2 
sleep %SendTime%
}
return

[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]

User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: [12/29/2021 UPDATE] [Script] Rapid Key Presser for World of Warcraft or other MMOs!

Post by boiler » 02 Dec 2022, 07:25

See @Dolbaebx’s topic on this subject here.

Please do not ask the same question in multiple places on the forum.

Post Reply

Return to “Gaming Scripts (v1)”