PyQT - Executing a program

Posted on 2011-05-06
Last Modified: 2012-05-11

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?

Question by:occ_user
    LVL 8

    Accepted 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 It can be invoked from python code with the ctypes module (or pywin32 with some extra work).

    Author Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Plenty of writing has gone on the web trying to compare Python with other competitive programming languages and vice versa. However, not much has been put into a wholistic perspective. This article should help you decide whether to adopt Python as a…
    When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
    Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
    Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now