feat(window_manager): use OpenInputDesktop in find_window_by_match and exclude Catser overlay
Ensures desktop window enumeration accesses the user's interactive desktop station across multiple monitors and ignores Catser's own overlay window.
This commit is contained in:
@@ -174,7 +174,9 @@ class WindowManager:
|
|||||||
process_predicate: Optional[Callable[[str], bool]] = None,
|
process_predicate: Optional[Callable[[str], bool]] = None,
|
||||||
) -> Optional[WindowInfo]:
|
) -> Optional[WindowInfo]:
|
||||||
"""
|
"""
|
||||||
Enumerates top-level desktop windows to find the first matching window.
|
Enumerates top-level desktop windows to find the first matching visible window.
|
||||||
|
Uses the user's interactive input desktop to ensure windows across all monitors
|
||||||
|
are discovered even if the calling thread has a different default desktop.
|
||||||
"""
|
"""
|
||||||
found_hwnd = None
|
found_hwnd = None
|
||||||
|
|
||||||
@@ -189,6 +191,10 @@ class WindowManager:
|
|||||||
if not title:
|
if not title:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# Never target Catser's own overlay window
|
||||||
|
if "catser overlay" in title.lower():
|
||||||
|
return True
|
||||||
|
|
||||||
if title_predicate and title_predicate(title):
|
if title_predicate and title_predicate(title):
|
||||||
found_hwnd = hwnd
|
found_hwnd = hwnd
|
||||||
return False # Stop enumeration
|
return False # Stop enumeration
|
||||||
@@ -201,7 +207,12 @@ class WindowManager:
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
user32.EnumWindows(WNDENUMPROC(enum_proc), 0)
|
h_input_desk = user32.OpenInputDesktop(0, False, 0x01FF)
|
||||||
|
if h_input_desk:
|
||||||
|
user32.EnumDesktopWindows(h_input_desk, WNDENUMPROC(enum_proc), 0)
|
||||||
|
user32.CloseDesktop(h_input_desk)
|
||||||
|
else:
|
||||||
|
user32.EnumWindows(WNDENUMPROC(enum_proc), 0)
|
||||||
|
|
||||||
if found_hwnd:
|
if found_hwnd:
|
||||||
return cls.get_window_info(found_hwnd)
|
return cls.get_window_info(found_hwnd)
|
||||||
|
|||||||
Reference in New Issue
Block a user