Is there a way to use this for dynamic hotkeys as well? For example:
Hotkey, If (expression) ;would be to #If (expression) ;as Hotkey, IfWinActive, somewindow ;is to #IfWinActive, somewindow
Hotkey, If (expression) ;would be to #If (expression) ;as Hotkey, IfWinActive, somewindow ;is to #IfWinActive, somewindow
Hotkey, If, Expression ;is to #If, Expression ;as Hotkey, IfWinActive, somewindow ;is to #IfWinActive, somewindowThe comma is optional for #If, but required for Hotkey, If. Expression must match an existing #If, Expression exactly, including case but excluding trailing or leading spaces or tabs. ErrorLevel is set to 1 if it does not exist somewhere in the script.
#If, expression1 Enter:: MsgBox #If, expression2 G:: MsgBox Hotkey, If, expression1
G:: MsgBoxThis is a single-line hotkey, which will not execute the line below it. Other than that, your example should work. The #If expression can be anywhere in any file #included in the current script.