[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1009
  • Last Modified:

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?

1 Solution
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 http://www.autoitscript.com/site/autoit/downloads/. 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.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now