Search code examples
pythonuser-interfaceautomationpywinauto

Pwinauto: How to start an application without GUI error


I am trying to open up a program with pywinauto then open a specific file in the program, but I am getting this error:

  File "C:\ProgramData\Anaconda3\lib\site-packages\pywinauto\application.py", line 1043, in app_idle
    h_process, int(timeout * 1000))

error: (1471, 'WaitForInputIdle', 'Unable to finish the requested operation because the specified process is not a GUI process.')

What is this error and how would I launch this application then click on File then open?

I have tried to add the timeout parameter, but I was not successful with that. Also I tried to connect to the app whenever it was already launched, and I wasn't able to connect when using the title. Here is my code:

import pywinauto

from pywinauto.application import Application

app = Application().start(r'c:\Program Files\ANSYS Inc\v191\CFX\bin\cfx5pre.exe', timeout=20)

app.CFX-Pre.menu_select("File->Open Case")

Solution

  • Maybe this app has console launcher that spawns child GUI process. Please try .start(..., wait_for_idle=False) and then .connect(...) to child process.