How do I get a list of the name/text of all opened windows?
I tried pywinauto:
pywinauto.findwindows.find_windows(title_re="*")
but using *
as a regex raises an error
I tried win32gui: It has
win32gui.GetWindowText(win32gui.GetForegroundWindow())
But in its docs I couldn't find a getAllWindows or something that returns all names/texts of open hwnd handles: http://timgolden.me.uk/pywin32-docs/contents.html
If you want using pywinauto, it's much easier:
This should work even for WPF applications. Using
win32gui.EnumWindows
can't access texts for WPF or UWP applications. pywinauto useswin32gui.EnumWindows
insideDesktop(backend="win32")
.backend="uia"
uses newer API fromUIAutomationCore.dll
.More details about backends in pywinauto can be found in the Getting Started Guide.
You can use
win32gui.GetWindowText( hwnd )
along withwin32gui.EnumWindows
:Output: