AutoFire with SetTimer and getKeyState interrupted by any key

Ask gaming related questions (AHK v1.1 and older)
eyelinerz
Posts: 2
Joined: 02 Dec 2021, 13:34

AutoFire with SetTimer and getKeyState interrupted by any key

Post by eyelinerz » 02 Dec 2021, 13:52

Hi there!
I've been using AHK for several years now by coding some simple AutoFire scripts to play MMO's.
I've changed my computer recently and transfered all my scripts on my new machine.
Since then my scripts do not behave exactly the same and after hours of investigations I can't figure out why.
I turn to you the AHK community to help me figure out what's goin on!
Here is the script I use:

Code: Select all

#NoEnv  
SendMode Input  
SetWorkingDir %A_ScriptDir% 
#InstallKeybdHook
#UseHook

#IfWinActive Star Wars™: The Old Republic™
$é::
	GoSub, AutoFire
Return
#IfWinActive

AutoFire:
	Send, {é}{l}{s}{d}{j}
	if(getKeyState("é",P)){
	SetTimer, AutoFire, -100	
	}
return
	
The behavior I had from this script was as follow:
I kept my finger on the {é} to trigger the autoshoot continuously and was able to straff on right and left using {a} and {e} and the AutoFire function kept being triggered.
Now, the Autofire is no longer triggered from the moment I press anyother key, so I have to re apply the {é} key.
Do you have any lead please? :)

Wishing yall a great night/day.

Eyelinerz

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: AutoFire with SetTimer and getKeyState interrupted by any key

Post by mikeyww » 02 Dec 2021, 17:26

Instead of using variable P, use the expression "P".

Explained: GetKeyState

eyelinerz
Posts: 2
Joined: 02 Dec 2021, 13:34

Re: AutoFire with SetTimer and getKeyState interrupted by any key

Post by eyelinerz » 03 Dec 2021, 01:48

Many thanks mikeyww this works perfectly :)

Post Reply

Return to “Gaming Help (v1)”