2 Key that modify each other into a 3rd key Topic is solved

Ask gaming related questions (AHK v1.1 and older)
Mommy_Lilith
Posts: 3
Joined: 07 Sep 2022, 10:27

2 Key that modify each other into a 3rd key

07 Sep 2022, 10:58

Hi,
When holding both LShift and W (regardless of which one was pressed first),
I want them both to be blocked and replaced by a new Key, say X (held until the either of other 2 keys are released).

My Use case?
Your character in some hypothetical game, walks slow while holding W, But Runs fast while holding X.
And You and I both would rather Use Shift+W to sprint instead, No?

I've spent my whole today trying to figure out how to script that with no avail. (and i'm a dummy with no scripting knowledge)
I got very close, but there's always one annoying issue;
Pressing Shift while W is held down, wont trigger X, and wont Block W

Again:
I want both Shift and W function normally while NOT held down simultaneously, but both Blocked and Replaced by X when Held Down Together, No matter which one was pressed first.


just a few of my attemps:

Code: Select all

~w::SendInput, {u Up}
#IF GetKeyState("LShift","P") or #IF GetKeyState("w","P") 
LShift::x
w::x
#IF

Code: Select all

Lshift & w::
w & LShift::
Sendinput {x down}
Sendinput {x up}
I will greatly and deeply appreciate anyone who can offer some help.
thinkRand
Posts: 44
Joined: 02 Mar 2022, 04:16
Location: Somewhere in Venezuela
Contact:

Re: 2 Key that modify each other into a 3rd key

07 Sep 2022, 17:04

Hi, @Mommy_Lilith. Welcome.

Itried this and it may work good enought for you, but have some issues

Code: Select all

~LShift & w:: ;Issue, send w or W sometimes
~w & LShift:: ;Issue, LShift is sent repeatedly, may stuck
	Send, x
return
Discord: thinkRand#7433 (UID 681695022600814642)
Mommy_Lilith
Posts: 3
Joined: 07 Sep 2022, 10:27

Re: 2 Key that modify each other into a 3rd key

07 Sep 2022, 22:49

Hi @thinkRand and thank you for the effort.

Unfortunately your code doesn't stop and block W and LShift and keeps spamming them after they've been combined.
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: 2 Key that modify each other into a 3rd key  Topic is solved

07 Sep 2022, 23:02

Maybe:

Code: Select all

#IF GetKeyState("w","P") 
LShift::x
#IF GetKeyState("LShift","P")
w::x
#IF
Mommy_Lilith
Posts: 3
Joined: 07 Sep 2022, 10:27

Re: 2 Key that modify each other into a 3rd key

10 Sep 2022, 12:06

Xtra wrote:
07 Sep 2022, 23:02
Maybe:

Code: Select all

#IF GetKeyState("w","P") 
LShift::x
#IF GetKeyState("LShift","P")
w::x
#IF
IT WORKS!
Exactly how i wanted it!

So those # did all the trick for some reason, and i have no idea why.
Gotta read more before jumping into endless trial and errors...

Thank you Xtra!

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: trane18 and 68 guests