Remapping z to Ctrl+z but space + z = z

Ask gaming related questions (AHK v1.1 and older)
Speedster448
Posts: 2
Joined: 20 Jan 2022, 08:10

Remapping z to Ctrl+z but space + z = z

Post by Speedster448 » 20 Jan 2022, 08:17

Hi I am trying to setup hotkeys for Starcraft 2 but some of the hotkey setting functions do not have the double hotkey feature enabled for example adding an attachment to a building to work around this I was trying to make a script that binds the z key to perform z+ctrl
so:
z = z+ctrl

but if spacebar is pressed
space + z = z (allowing the z key alone to still be triggered)

i am going to do the same for x, c & v keys, it seems like some general knowledge of this language is needed to perform this, so help would be appreciated thank you.

Speedster448
Posts: 2
Joined: 20 Jan 2022, 08:10

Re: Remapping z to Ctrl+z but space + z = z

Post by Speedster448 » 20 Jan 2022, 08:48

i got this to work through trial and error

Code: Select all

z:: send ^z
space & z:: z
that seems to be one solution
however is there a way to fancy it up be creating an if statement so that in psedo-code would be something like:

Code: Select all

if(!space{not pressed})
z:: send ^z
else(space{held/pressed})
z :: z
?? Thanks for any help again

Rohwedder
Posts: 7558
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Remapping z to Ctrl+z but space + z = z

Post by Rohwedder » 20 Jan 2022, 12:33

Hallo,
try:

Code: Select all

*z::Send,% GetKeyState(A_Space,"P")?"z":"^z"

Post Reply

Return to “Gaming Help (v1)”