ayaan
ayaan

Reputation: 735

run an executable file in the background and prevent it from opening windows using python

I have a pre installed application in my computer which basically counts the number of mouse clicks on the desktop screen. Now i want to make this application run as a background process. So i wanted to write a python script which can make this application run as a background process when i run the script. I don't want the application window to appear on the screen.How can i do this? i'm thinking of using subprocess.Popen()

the code which i wrote is as follows:

proc=subprocess.Popen(['/home/Desktop/mousecounter'],stdin=subprocess.PIPE,shell=True,preexec_fn=os.setsid)

But when i use this the applications pops out on the desktop screen which i don't want. how to do this?

Upvotes: 0

Views: 128

Answers (1)

Aaron Digulla
Aaron Digulla

Reputation: 328764

Python can't prevent a child process from opening windows. That also means it can't turn something with a UI into a daemon / background process.

You will have to look into the documentation of the application mousecounter to see whether it supports command line options to hide / disable the window.

Upvotes: 3

Related Questions