I am trying to return all windows from my machine using PyAutoWin. The ultimate goal is to later narrow down this list to a subset of windows to automate (resize and perform scraping actions) using a mixture of methods.
However I am failing at the most basic task: returning all windows. My code is:
import pywinauto
print(pywinauto.findwindows.enum_windows())
and getting this error:
Traceback (most recent call last):
File "app.py", line 4, in <module>
print(pywinauto.findwindows.enum_windows())
File "C:\Users\*\.virtualenvs\scraper-j58Iv-wO\lib\site-packages\pywinauto\findwindows.py", line 368, in enum_windows
win32functions.EnumWindows(proc, 0)
ctypes.ArgumentError: argument 1: <class 'TypeError'>: expected WinFunctionType instance instead of WinFunctionType
I tried instantiating a Desktop() object and passing it to the enum_windows() method but it does not take in argument.
Any help is greatly appreciated!
Best regards
The right way to do that:
from pywinauto import Desktop
top_windows = Desktop(backend="uia").windows() # or backend="win32" by default
# walk the returned list of wrappers
for w in top_windows:
print(w.window_text())