| 639 | |
| 640 | |
| 641 | HWND 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 |
no test coverage detected