on-internet
← Community

Reliably finding and screenshotting Windows 11 XAML context menus (PopupHost) with pywinauto / UIA?

Stack Overflow ·

I'm trying to automate taking cropped screenshots of Windows 11 UI steps (context menus, Run dialog, Registry Editor, Task Manager) using Python (pywinauto with backend="uia", pyautogui, and mss). The script works fine on classic Win32 dialogs, but it breaks constantly on Windows 11's newer XAML / WinUI 3 surfaces: On the new right-click context menu (PopupHost), Desktop(backend="uia") either times out traversing the tree or returns stale coordinates, and the menu immediately closes if anything steals focus. Using pygetwindow.getActiveWindow() + mss often captures the underlying Explorer windo

Comments

Sign in or sign up to comment and upvote.

No comments yet.