Hi,
In my AHK script I want to map the Z key to modifier keys such as ctrl+alt. I want it to work for the duration that I hold down Z, just like modifier keys usually behave.
Using:
z & LButton::^!MButton
Doesn't seem to have the effect that I want, it doesn't seem to hold it down.
What is the proper way to have a letter key as a modifier?
Many thanks.
Mapping the Z key to a modifier key
Re: Mapping the Z key to a modifier key
Welcome to this AutoHotkey forum!
Code: Select all
z::
Send {Ctrl down}{Alt down}
KeyWait, z
Send {Alt up}{Ctrl up}
Return
Re: Mapping the Z key to a modifier key
Hallo,
The docs say:
When a script is launched, each remapping is translated into a pair of hotkeys. For example, a script containing a::b actually contains the following two hotkeys instead:
Using the remapping translation to map the Z key to modifier keys such as ctrl+alt
is not possible for two reasons:
1. the two map hotkeys use {Blind}.
2. the first map hotkey holds only a single key DownR.
Your wish: I want it to work for the duration that I hold down Z, just like modifier keys usually behave. is also based on two errors!
1. A user-defined combination of two keys is not triggered by the state of the prefix key (here key Z).
2. Sent modifier keys like in Send, ^!{MButton Down} do not stay pressed.
I suppose what you actually want is:but it will work only for the duration of holding down LButton.
The docs say:
When a script is launched, each remapping is translated into a pair of hotkeys. For example, a script containing a::b actually contains the following two hotkeys instead:
Code: Select all
*a::
SetKeyDelay -1
Send {Blind}{b DownR}
Return
*a up::
SetKeyDelay -1
Send {Blind}{b Up}
Return
is not possible for two reasons:
1. the two map hotkeys use {Blind}.
2. the first map hotkey holds only a single key DownR.
Your wish: I want it to work for the duration that I hold down Z, just like modifier keys usually behave. is also based on two errors!
1. A user-defined combination of two keys is not triggered by the state of the prefix key (here key Z).
2. Sent modifier keys like in Send, ^!{MButton Down} do not stay pressed.
I suppose what you actually want is:
Code: Select all
z & LButton::SendInput, {Ctrl down}{Alt down}{MButton DownR}
z & LButton Up::SendInput, {Ctrl Up}{Alt Up}{MButton Up}
Re: Mapping the Z key to a modifier key
Thanks for all of the help guys, I am getting the result I'm looking for now!