Search code examples
pythonpywinauto

Pywinauto - Can't connect to office documents using the UIA backend


I'm having an unusual problem lately that when I open some excel/word document and try to connect to it's process using -

app = pywinauto.Application(backend="uia").connect(process=19812)

It seems not to work, meaning that app.is_process_running() returns False and the top_window() method raises the RuntimeError(No windows for that process could be found) exception.

But if I run the actual executable program (Winword.exe or Excel.exe and not some *.xls file), it seems to work properly and everything seems to work fine.

I checked the UIA compatibility with inspect.exe on the documents and everything seems to be fine.

What can be the problem here?


Solution

  • Running the python script with admin privileges solved the problem :\