Force-stop moving script

Ask gaming related questions (AHK v1.1 and older)
AHKBeginner
Posts: 1
Joined: 20 Jan 2015, 11:22

Force-stop moving script

20 Jan 2015, 12:32

I'm trying to write a script for an FPS game. The idea is very simple. When player releases one of the movement keys (W-A-S-D) the character still keeps "sliding" for a second. This leads to few first shots inaccuracy.
I see two ways of implementation. First one is tapping the opposite direction keys (I release A key, script presses D key, I release D key, script presses A key etc). Second one is stoping all movement when LMB is pressed/held (not sure about this one).

So I did something like this:

Code: Select all

~*a up::
SendInput {d down}
Sleep 130
SendInput {d up}
return

~*d up::
SendInput {a down}
Sleep 130
SendInput {a up}
return
First of all game doesn't recognize Send/SendInput unless I use sleep. Too low values lead to no effect at all, too high - to moving in opposite direction. The problem is when I release A and in the exact same time push D I get stuck and can't move for a sleep time (?). Basicly you can't peek around corners while this bug is present. Any help?
jpginc
Posts: 124
Joined: 29 Sep 2013, 22:35

Re: Force-stop moving script

09 Feb 2015, 04:46

hmmm try using KeyWait http://ahkscript.org/docs/commands/KeyWait.htm instead of sleep. I think what might be happening is that you press the D key and then a few miliseconds later the script lifts it up pragmatically. If you make it

Code: Select all

;Wait for key d to be pushed down, wiat for 130ms
KeyWait, d, DT0.13
if(errorlevel)
{
    ;the d key wasn't pressed by the user so lift it up
    SendInput {d up}
} else
{
    ;the user has pressed the d key so let them release it
}
Hope that helps

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 83 guests