Within ClosePopups.ahk:
Code: Select all
Loop ;That looks for popup windows and closes them
{
IfWinExist
close popup functions
}
#Include Hotkeys.ahk ;This contains hotkey and hotstrings
[Mod note: Topic name and code tags added.]
Code: Select all
Loop ;That looks for popup windows and closes them
{
IfWinExist
close popup functions
}
#Include Hotkeys.ahk ;This contains hotkey and hotstrings
Code: Select all
#If WinActive("My App")
; Put hotkeys for My App here
#If WinActive("My Other App")
; Put hotkeys for My Other App here
In AHK v1.1, I would actually still prefer #IfWinActive over #If WinActive(), if the use case allows it - because they work differently, and the expression is a potential disadvantage in simple calls that could have otherwise been done with the #IfWin directives.
versus #If:https://autohotkey.com/docs/commands/_IfWinActive.htm#gen wrote:For performance reasons, #IfWin does not continuously monitor the activation or existence of the specified windows. Instead, it checks for a matching window only when you type a hotkey or hotstring. If a matching window is not present, your keystroke or mouse click is allowed to pass through to the active window unaltered.
(There are more caveats for #If mentioned in https://autohotkey.com/docs/commands/_If.htm#General_Remarks)https://autohotkey.com/docs/commands/_If.htm#General_Remarks wrote:Note: Scripts should not assume that the expression is only evaluated when the key is pressed (see below).
The expression may also be evaluated whenever the program needs to know whether the hotkey is active. For example, the #If expression for a custom combination like a & b:: might be evaluated when the prefix key (a in this example) is pressed, to determine whether it should act as a custom modifier key.
Note: Use of #If in an unresponsive script may cause input lag or break hotkeys (see below).
https://lexikos.github.io/v2/docs/commands/_If.htm#optimization wrote:#If is optimized to avoid expression evaluation for simple calls to WinActive or WinExist, thereby reducing the risk of lag or other issues in such cases. Specifically:
The expression must contain exactly one call to WinExist or WinActive.
[...]