Hallo,
this version produces, as expected, the Error: Duplicate label
Code: Select all
q::Goto, +1
+1::SoundBeep, 4000, 20
+1:
SoundBeep, 1000, 20
Return
Code: Select all
q::Goto, +1
+1:
SoundBeep, 1000, 20
Return
+1::SoundBeep, 4000, 20
Code: Select all
q::Goto, +1
+1::SoundBeep, 4000, 20
+1:
SoundBeep, 1000, 20
Return
Code: Select all
q::Goto, +1
+1:
SoundBeep, 1000, 20
Return
+1::SoundBeep, 4000, 20
Code: Select all
; (0) parsing starts
+1: ; (1) this is a regular label. does a duplicate hotkey/hotstring/regular name exist? no, add this label
MsgBox label
return
#If true
+1::MsgBox true ; (2) this is a hotkey label. dont check for duplicate labels, add this label
#If false
+1::MsgBox false ; (3) this is a hotkey label. dont check for duplicate labels, add this label
Code: Select all
; (0) parsing starts
#If true
+1::MsgBox true ; (1) this is a hotkey label. dont check for duplicate labels, add this label
+1: ; (2) this is a regular label. does a duplicate hotkey/hotstring/regular name exist? yes - due to (1), so fail parsing
MsgBox label
return
#If false
+1::MsgBox false
Although the current explanation does not take into account normal labels. The actual and expected behaviour is that when there are duplicate labels, the label first encountered during parsing ("closest to the top of the script") is used. It is possible to create a set of hotkey variants where each variant can be addressed by gosub, such as with ^+a and +^a.Hotkey and hotstring labels are also valid targets for Goto, Gosub and other commands. However, if a hotkey or hotstring has multiple variants, the variant closest to the top of the script is used.
Source: Labels - Syntax & Usage | AutoHotkey