I am running a Python script on windows 7 that opens a subprocess every few seconds. This subprocess opens a window and grabs focus, disrupting any attempt by the user to do normal work while the script is running. I do not have the ability to modify the subprocess code itself. Is there a way to designate all subprocesses opened by a python script as not-focused?
CLARIFICATION: I need the window to open and be viewable/selectable, just not immediately jump on top of everything else that is going on. In other words, it need to open in the background, not force itself into the foreground.
Here is how I did this last
# Hide the cmd prompt window
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
startupinfo.wShowWindow = subprocess.SW_HIDE
p = subprocess.Popen(args, startupinfo=startupinfo)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With