Hotkey subroutine is executed without pressing a key

Report problems with documented functionality
john_c
Posts: 493
Joined: 05 May 2017, 13:19

Hotkey subroutine is executed without pressing a key

23 Sep 2020, 11:50

Directives are executed unconditionally and hence it makes no sense to place them inside if.

I intentionally violate this rule to show the weird behavior caused by such a violation.

Code: Select all

; Expected: Regardless of Var1 is False, F12 (when pressed) will produce "Foo"
; Actual: You will see "Foo" at the first launch. There is no need to press F12 key to see it.

#SingleInstance Force
Var1 := False
Var2 := True

If (Var1)
    #If Var2
        F12:: MsgBox Foo
lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: Hotkey subroutine is executed without pressing a key

27 Feb 2021, 22:48

This has nothing to do with the directive. The issue is that the script's first hotkey literally behaves as though return was placed above the label (and any labels stacked above it), and you are preventing this implicit return from executing, by making it conditional upon Var1, which is false.
The Top of the Script (the Auto-execute Section) wrote:Note: While the script's first hotkey/hotstring label has the same effect as return, other hotkeys and labels do not.
(Emphasis added.)

I do not intend to fix this, but it does not affect v2 anyway, since hotkeys work differently.

Return to “Bug Reports”

Who is online

Users browsing this forum: docterry and 30 guests