Search code examples
pythontimedelay

Is there a way of opening an external .exe which doesn't pause the rest of the program? python


I am writing a python program (3.8) which is automatically filling in certain options in a command window using a menu format. For example, when prompted with

enter image description here

It would fill the correct option (either 1 or 2).

Currently, the .exe file must be opened separately from the python file which is a hassle. To remove this I tried using subprocess like this.

import subprocess 
subprocess.call([r'C:\Users\file\location\that\ends\right\here\VSCaptureMP.exe'])

but it pauses the entire program until the .exe window is closed. The rest of the program (the automatic writing part) never gets to run when using this format.

I know there is an after module when using tkinter. Is there a similar option for this scenario?


Solution

  • Use subprocess.Popen

    import subprocess
    
    print("Hello")
    subprocess.Popen([r"C:\Windows\system32\mspaint.exe"])
    print("This is non-blocking!")