Up & right arrow key as hotkey Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
M4verick
Posts: 193
Joined: 03 Nov 2020, 12:00

Up & right arrow key as hotkey

12 Apr 2021, 20:27

I created a simple script.

Code: Select all

Up & Right::Run, Firefox.exe -private-window https://www.website.com
The script works just fine and the custom combination key runs the script as intended. However, I have a slight problem.
Since loading this script into memory, I've discovered that my up arrow key doesn't do anything at all. Whenever I'm typing in MS Word as an example, I have to always suspend the hotkeys so can move the cursors up. Is there anything else i can do besides suspend the hotkeys?

(Strangely enough, my right arrow key responds just fine in MS Word).

EDIT: To clarify, I'm not asking for another hotkey... I'm just asking if there's a better way to write the script.
Last edited by M4verick on 12 Apr 2021, 20:31, edited 2 times in total.
gregster
Posts: 9056
Joined: 30 Sep 2013, 06:48

Re: Up & right arrow key as hotkey  Topic is solved

12 Apr 2021, 22:08

This is actually expected behaviour for a hotkey custom combination - the prefix key will lose its native function.
So, you will actually need another hotkey to work around this:
https://www.autohotkey.com/docs/Hotkeys.htm#combo wrote: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:

Code: Select all

Numpad0 & Numpad1::MsgBox You pressed Numpad1 while holding down Numpad0.
Numpad0 & Numpad2::Run Notepad

The prefix key loses its native function:
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:

Code: Select all

Numpad0::WinMaximize A   ; Maximize the active/foreground window.
Numpad0::Send {Numpad0}  ; Make the release of Numpad0 produce a Numpad0 keystroke. See comment below.
Fire on release: The presence of one of the above custom combination 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. [v1.1.14+]: This behaviour can be avoided by applying the tilde prefix to either hotkey.
That means, you can do this:

Code: Select all

Up & Right::Run, Firefox.exe -private-window https://www.website.com
Up::Send {Up}		; fires on release of the key
As documented, alternatively, adding a tilde modifier would also be possible (eg, ~Up & Right::) - but when you want to run Firefox, you probably do not want Up's or Right's original function to be executed at the same time... thus, a separate Up::Send {Up} hotkey, which fires on release only, is often the better alternative. But that choice is up to you.
M4verick
Posts: 193
Joined: 03 Nov 2020, 12:00

Re: Up & right arrow key as hotkey

12 Apr 2021, 23:30

Thanks Gregster. I appreciate the explanation and the solution.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], jdfnnl and 145 guests