PyQT - Executing a program


I am trying to run an exe on the click of a button from a PyQt gui. I am trying to use a QProcess to do this. When run from command line, the exe doesn't accept command line parameters, but instead prompts the user for input (a file name) after the program has started.
Is there any way I can pass this input to the exe through a QProcess so that the exe will run and continue running without waiting for input from the user?

Who is Participating?
LunarNRGConnect With a Mentor Commented:
Unfortunately, unless there's something special about the GUI program that you haven't described, the short answer to your question is no. There isn't a way, that I am aware, to automate a GUI program from PyQT directly.

The long answer (yes!) would involve invoking some sort of GUI automation tool that would wait for the window handle of the input dialog, send the text to the correct form field, and then perhaps click a button. To this end, you may want to have a look at AutoItX from It can be invoked from python code with the ctypes module (or pywin32 with some extra work).
occ_userAuthor Commented:
Thank you.
I was able to get the person who created the exe to recompile to accept command line arguments afterall, so fortunately this won't be necessary.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.