MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / GetValidLastUsedWindow

Function GetValidLastUsedWindow

source/window.cpp:641–658  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

639
640
641HWND GetValidLastUsedWindow(global_struct &aSettings)
642// If the last found window is one of the script's own GUI windows, it is considered valid even if
643// DetectHiddenWindows is ON. Note that this exemption does not apply to things like "IfWinExist,
644// My Gui Title", "WinActivate, ahk_id <gui id>", etc.
645// A GUI window can become the last found window while DetectHiddenWindows is ON in two ways:
646// Gui +LastFound
647// The launch of a GUI thread that explicitly set the last found window to be that GUI window.
648{
649 if (!aSettings.hWndLastUsed || !IsWindow(aSettings.hWndLastUsed))
650 return NULL;
651 if ( aSettings.DetectWindow(aSettings.hWndLastUsed)
652 || (GetWindowLong(aSettings.hWndLastUsed, GWL_STYLE) & WS_CHILD) ) // v1.0.40.05: Child windows (via ahk_id) are always detectible.
653 return aSettings.hWndLastUsed;
654 // Otherwise, DetectHiddenWindows is OFF and the window is not visible. Return NULL
655 // unless this is a GUI window belonging to this particular script, in which case
656 // the setting of DetectHiddenWindows is ignored (as of v1.0.25.13).
657 return GuiType::FindGui(aSettings.hWndLastUsed) ? aSettings.hWndLastUsed : NULL;
658}
659
660
661

Callers 4

WinActivateFunction · 0.85
WinCloseFunction · 0.85
WinActiveFunction · 0.85
WinExistFunction · 0.85

Calls 1

DetectWindowMethod · 0.80

Tested by

no test coverage detected