1

I am sorry if this has been discussed before, but I didn't find a confirmative answer after I searched this topic in the forum.

Long story short, I have a very simply python snippet that used to work in Windows 10.

from pywinauto import application
app = application.Application()
app.start('Notepad.exe')
app.top_window().PrintControlIdentifiers()

After updating to Windows 11, I get the following error when trying to run the same code, "...Python\Python39\lib\site-packages\pywinauto\application.py", line 1156, in top_window raise RuntimeError("No windows for that process could be found") RuntimeError: No windows for that process could be found"

Does this mean pywinauto is not compatible with Windows 11? I have pywinauto 0.6.8 installed with python 3.9.6 64-bit

Thanks.

In my test, it seems the Desktop class of pywinauto library is still working. But this quoted snippet uses the Application class. For some reason it stops working in Windows 11.

3
  • Notepad application is significantly changed in Win11. So example scripts which work on Win10 may not work on Win11 if it is a system application. Also .top_window() is not recommended to use. It can catch top window at random moment and freeze it. So real top window will change, but you will still refer to old top window. Commented Aug 18, 2024 at 13:53
  • 1
    I think I found the solution to this problem. Instead of directly calling the window() method, we have to call the connect() function with the correct pid value. And after that we will be able to repeat all those available with Windows 10. Commented Aug 19, 2024 at 19:59
  • .connect(title="...", timeout=10) should work as well. There is known problem with zero timeout if it is not mentioned. Also title_re should work. This is more reliable than PID which is different each time. Commented Aug 20, 2024 at 8:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.