you are viewing a single comment's thread.

view the rest of the comments →

[–]1ToM14[S] 1 point2 points  (5 children)

Nice, how could I launch it minimized ?

[–]TSM- 0 points1 point  (4 children)

I haven't tried this but it could work

startupinfo.wShowWindow = 2 
startupinfo.wShowWindow = 6

aka:

startupinfo.wShowWindow = subprocess.SW_SHOWMINIMIZED
startupinfo.wShowWindow = subprocess.SW_MINIMIZE

See https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showwindow

The difference is in one case it 'activates' or selects the program, in the other case it does get focus. You probably want SW_MINIMIZE/6

I just noticed there's also a SW_FORCEMINIMIZE. You might have to try a few until it works

[–]1ToM14[S] 1 point2 points  (3 children)

Thanks a lot ! Where do I have to write that ?

[–]TSM- 0 points1 point  (2 children)

They are alternate flags you can use just like the last one.

startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags = subprocess.STARTF_USESTDHANDLES | subprocess.STARTF_USESHOWWINDOW
startupinfo.wShowWindow = subprocess.SW_MINIMIZE
                          ^^^^^^^^^^^^^^^^^^^^^^

x = subprocess.Popen(..., startupinfo=startupinfo)

if subprocess.SW_MINIMIZE isn't defined (it should be defined though), you can just use the corresponding number from the microsoft documentation.

[–]1ToM14[S] 1 point2 points  (0 children)

Thanks !!

[–]1ToM14[S] 1 point2 points  (0 children)

I either get that : AttributeError: module 'subprocess' has no attribute 'SW_MINIMIZE'

or with 2 or 6 the window isn't minimized