Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

AutoHotkey_L: Arrays, Debugger, x64, COM, #If expression ...


  • This topic is locked This topic is locked
33 replies to this topic
Krogdor
  • Members
  • 1391 posts
  • Last active: Jun 08 2011 05:31 AM
  • Joined: 18 Apr 2008
A question about #If (expression)
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


Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
I forgot to document the following:

Use Hotkey, If, Expression to modify or create hotkey variants under an existing #If, Expression. For example:
Hotkey, If, Expression
;is to
#If, Expression
;as
Hotkey, IfWinActive, somewindow
;is to
#IfWinActive, somewindow
The 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.

(The ability to create new #If expressions with the Hotkey command is planned.)

Krogdor
  • Members
  • 1391 posts
  • Last active: Jun 08 2011 05:31 AM
  • Joined: 18 Apr 2008
Aha!

Great, thanks Lexikos.

Also, just for clarification—the #If expression just has to be declared somewhere in the script, but it doesn't have to be the one directly before the Hotkey, If command, right? For example:

#If, expression1
Enter:: MsgBox
#If, expression2
G:: MsgBox
Hotkey, If, expression1

is valid?

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
G:: MsgBox
This 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.