Hold a key While i'm Holding another key

Ask gaming related questions (AHK v1.1 and older)
mitnak
Posts: 4
Joined: 14 Mar 2018, 11:19

Hold a key While i'm Holding another key

14 Mar 2018, 11:31

Hello, i'm totaly new in this and i would like to create a script that would hold the Shift key anytime i would press and hold the z key.

This is what i did but it doesn't seem to work...

Code: Select all

$z::
GetKeyState, state, z
If state = D
sendinput, {Shift down}
else
sendinput, {Shift up}
return
Anyone could help me with that?

Thx in advance
Rindis
Posts: 213
Joined: 23 Dec 2013, 13:58
Location: Norway
Contact:

Re: Hold a key While i'm Holding another key

15 Mar 2018, 03:27

Code: Select all

$z::
	send, +z
	
return
Rohwedder
Posts: 7679
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Hold a key While i'm Holding another key

15 Mar 2018, 03:28

Hallo,
try this Remapping:
https://autohotkey.com/docs/misc/Remap.htm

Code: Select all

z::Shift
mitnak
Posts: 4
Joined: 14 Mar 2018, 11:19

Re: Hold a key While i'm Holding another key

15 Mar 2018, 10:05

Thanks for your help, apparently none of this 2 options seemed to make it work... i finaly managed to do it using this :

Code: Select all

flag = 0
z:: 
GetKeyState , state, z
if state = D
{
    if flag = 1
        return
        sendinput, {Shift down}
flag = 0
}
else
{
flag = 1
GetKeyState , state, z
if state = U
	sendinput, {Shift up}
flag = 1
    Return
}
The only issue now is : the srcipt seem to stop working when i go inside a vehicule and go back to foot...

Any idea why?

Thanks for your help
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: Hold a key While i'm Holding another key

15 Mar 2018, 10:55

Why didn't you remap like Rohwedder suggested though? I don't see why you need to complicate it so much.. both scripts are trying to perform the same function right?
Maybe going in to the car does not allow you to spam z (when you click and hold you are spamming that hotkey, and your hotkey only works because of that reason)? Again another reason why remapping would be more helpful.
I am your average ahk newbie. Just.. a tat more cute. ;)
mitnak
Posts: 4
Joined: 14 Mar 2018, 11:19

Re: Hold a key While i'm Holding another key

15 Mar 2018, 11:33

Remapping doesn't seem to work... maybe it's because it's only replacing z by Shift? When I actually need both z and Shift to be on Hold...

The z function seem to work exactly the same way inside the car or by foot... that's why i don't understand maybe it's because i'm holding the z button for to long when i'm inside the car, it's like the script crashed or something...
Rohwedder
Posts: 7679
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Hold a key While i'm Holding another key

15 Mar 2018, 11:39

Hallo,
then try this Remapping:

Code: Select all

~z::Shift
mitnak
Posts: 4
Joined: 14 Mar 2018, 11:19

Re: Hold a key While i'm Holding another key

15 Mar 2018, 12:11

Great thx a lot it's working perfectly! Much simpler and no more issues...
Thx again!
rockywtf
Posts: 2
Joined: 19 Apr 2022, 14:36

Re: Hold a key While i'm Holding another key

23 Aug 2023, 06:05

mitnak wrote: Great thx a lot it's working perfectly! Much simpler and no more issues...
Thx again!
hey, can you post the script here please, i would really appreciate it
User avatar
boiler
Posts: 17065
Joined: 21 Dec 2014, 02:44

Re: Hold a key While i'm Holding another key

23 Aug 2023, 07:00

The script is posted here. It’s what Rohwedder posted. That’s the whole script.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 51 guests