Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Custom Combinations and a single key


  • Please log in to reply
No replies to this topic
adrianh
  • Members
  • 616 posts
  • Last active: Apr 07 2016 03:35 PM
  • Joined: 28 Oct 2012

Custom Combinations and Other Features [Windows NT/2000/XP or later]

You can define a custom combination of two keys (except joystick buttons) by using " & " between them. In the below example, you would hold down Numpad0 then press the second key to trigger the hotkey:

Numpad0 [b]&[/b] Numpad1::MsgBox You pressed Numpad1 while holding down Numpad0.
Numpad0 [b]&[/b] Numpad2::Run Notepad
In the above example, Numpad0 becomes a prefix key; but this also causes Numpad0 to lose its original/native function when it is pressed by itself. To avoid this, a script may configure Numpad0 to perform a new action such as one of the following:
Numpad0::WinMaximize A [i]; Maximize the active/foreground window.[/i]
Numpad0::Send {Numpad0} [i]; Make the [i]release[/i] of Numpad0 produce a Numpad0 keystroke. See comment below.[/i]
The presence of one of the above hotkeys causes the release of Numpad0 to perform the indicated action, but only if you did not press any other keys while Numpad0 was being held down.

I was thinking that this would be good to have if by prepending a ~ to the first key in the combo that it would be executed first and then have the rest executed. Like this:
Numpad0 [b]&[/b] Numpad2::
Run Notepad
Tooltip,
return

Numpad0::
Send {Numpad0} [i]; Make the [i]release[/i] of Numpad0 produce a Numpad0 keystroke.[/i]
Tooltip,
return

~Numpad0::Tooltip,Pressing 0 with 2 on numeric pad will bring up notepad

And this would be equivalent to:
Numpad0 [b]&[/b] Numpad2::
Run Notepad
Tooltip,
return

~Numpad0 Up::
;Send {Numpad0} [i]; Line not needed as key wasn't sucked up[/i]
Tooltip,
return

~Numpad0::Tooltip,Pressing 0 with 2 on numeric pad will bring up notepad

Just some thoughts.


Adrian

my library base
AHK_L is the bomb! With a whole lot of bug fixes, Unicode support, associative array objects, array like objects, classes and variadic functions, why wouldn't you switch?