0
votes

I have the oddest behavior happening in a script. In the following MWE, the Hotkey F2 declaration doesn't work as long as the F1 line is there. If I comment out line 2, then the F2 hotkey works just fine.

#SingleInstance, Force
F1::MsgBox You pressed F1
Hotkey F2, Alone
return

Alone:
MsgBox You pressed F2.
return

Is there an interaction between the double colon notation and the "Hotkey" command that causes this? Is there a way around this?

Of course this is part of a larger script with several different hotkeys defined. Double colon notation is used for most hotkeys in the code, but I think I have to use the Hotkey command for dynamic keys (say one defined via an ini file). This code is a part of a larger code set with static hotkeys (using double colon notation) and I can't change that part of the code.

I am running Autohotkey v1.1.25.02 on Windows Enterprise 1909 (OS Build 18363.720)

Note: I have noticed that if I put the double colon declarations after the Hotkey command (i.e. reordered lines 2 and 3) it seems to work. I don't know if that is an option. There is hundreds of lines of code in the original script. I'd still like to know what is happening to cause the behavior.

1

1 Answers

1
votes

You're creating a one-liner hotkey F1.
Code execution won't continue to the lines below.

Here's the syntax you're looking for:

#SingleInstance, Force

F1::
    MsgBox, You pressed F1
    Hotkey, F2, Alone
return

Alone:
    MsgBox, You pressed F2.
return