Keeping sprint (shift) pressed as long as any movement (wasd) is maintained Topic is solved

Ask gaming related questions (AHK v1.1 and older)
ouboss
Posts: 21
Joined: 10 Dec 2016, 04:24

Keeping sprint (shift) pressed as long as any movement (wasd) is maintained

10 Jun 2018, 15:16

Titanfall 2 is my gold standard for sprinting movement, and I'm trying to transfer it to other games. In Titanfall 2, one tap of sprint will keep you in a sprint state even if you are strafing directly left or right at the lesser, pure strafing speed. Once you return to any forward or diagonal forward movement, full sprint resumes. To release sprint, one has to release all movement keys or, I believe 's' cancels it as well but I don't remember 100%.

The following, based off of an evilC script, is getting me fairly close, but I'm finding that my w-aw-a-aw-w seems to reset movement to walk upon returning to w. Any ideas for improving this anyone?

Code: Select all

*$~w up::GoSub, move_up
*$~a up::GoSub, move_up
*$~s up::GoSub, move_up
*$~d up::GoSub, move_up
~w & LShift::GoSub, SprintAssist
~a & LShift::GoSub, SprintAssist
~s & LShift::GoSub, SprintAssist
~d & LShift::GoSub, SprintAssist
 
SprintAssist:
{	SendInput, {LShift Up}
	SendInput, {LShift DownTemp}
} Return
 
move_up:
keywait w
keywait a
keywait s
keywait d
SendInput, {LShift Up}
Return
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: Keeping sprint (shift) pressed as long as any movement (wasd) is maintained  Topic is solved

10 Jun 2018, 16:07

EvilC using KeyWait? :think: :wtf:

You could try something like this:

Code: Select all

*LShift::Send {Blind}{LShift down}
*LShift up::
*~w up::
*~a up::
*~s up::
*~d up::
	If GetKeyState("LShift") && !GetKeyState("w","p") && !GetKeyState("a","p") && !GetKeyState("s","p") && !GetKeyState("d","p") && !GetKeyState("LShift","p")
		Send {Blind}{LShift up}
Return
ouboss
Posts: 21
Joined: 10 Dec 2016, 04:24

Re: Keeping sprint (shift) pressed as long as any movement (wasd) is maintained

10 Jun 2018, 18:51

Above code is perfection, minus the random LControl's I'm seeing whenever alt is thrown into the mix, reproducible when I press shift+alt+any of wasd.

Code: Select all

57  011	 	d	0.13	w              	
57  011	h	u	0.11	w              	
44  020	 	d	0.02	d              	
44  020	h	u	0.09	d              	
41  01E	 	d	0.00	a              	
57  011	 	d	0.05	w              	
44  020	 	d	0.08	d              	
41  01E	h	u	0.00	a              	
57  011	h	u	0.01	w              	
41  01E	 	d	0.08	a              	
44  020	h	u	0.02	d              	
57  011	 	d	0.06	w              	
44  020	 	d	0.09	d              	
41  01E	h	u	0.00	a              	
57  011	h	u	0.00	w              	
44  020	h	u	0.05	d              	
A0  02A	h	u	0.00	LShift         	
A0  02A	i	u	0.00	LShift         	
A4  038	 	u	0.05	LAlt           	
A2  01D	i	d	0.00	LControl       	
A2  01D	i	u	0.00	LControl
ouboss
Posts: 21
Joined: 10 Dec 2016, 04:24

Re: Keeping sprint (shift) pressed as long as any movement (wasd) is maintained

11 Jun 2018, 06:53

Interesting read. Was able to get it working perfectly afterwards. Thanks.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Bing [Bot] and 59 guests