Determines whether invisible windows are "seen" by the script.
PrevSetting := DetectHiddenWindows(Setting)
Type: Boolean
If true, hidden window detection is enabled.
If false, hidden window detection is disabled.
Type: Integer (boolean)
This function returns the previous setting; either 0 (false) for disabled or 1 (true) for enabled.
By default, hidden window detection is disabled.
Turning on DetectHiddenWindows can make scripting harder in some cases since some hidden system windows might accidentally match the title or text of another window you're trying to work with. So most scripts should leave this setting turned off. However, turning it on may be useful if you wish to work with hidden windows directly without first using WinShow to unhide them.
All windowing functions except WinShow are affected by this setting, including WinActivate, WinActive, WinWait and WinExist. By contrast, WinShow will always unhide a hidden window even if hidden windows are not being detected.
Turning on DetectHiddenWindows is not necessary in the following cases:
WinShow(A_ScriptHwnd) or WinMoveTop(myGui), except with WinWait or WinWaitClose.Cloaked windows are also considered hidden. Cloaked windows, introduced with Windows 8, are windows on a non-active virtual desktop or UWP apps which have been suspended to improve performance, or more precisely to reduce their memory consumption. On Windows 10, the processes of those are indicated with a green leaf in the Task Manager. Such windows are hidden from view, but might still have the WS_VISIBLE window style.
The built-in variable A_DetectHiddenWindows contains the current setting and can also be assigned a new value instead of calling DetectHiddenWindows.
Every newly launched thread (such as a hotkey, custom menu item, or timed subroutine) starts off fresh with the default setting for this function. That default may be changed by using this function during script startup.