Skip to content Skip to sidebar Skip to footer

Subprocess.popen Sets Size And Location Of The External Executed Programme?

I would like to execute an external programme from python via subprocess.Popen. I am wondering whether it is possible to set size and location of the window for the external progra

Solution 1:

I assume Windows for such a question?

You may specify the window to be minimized or maximized, using the startupinfo parameter of popen.

si = subprocess.STARTUPINFO()
si.dwFlags = subprocess.STARTF_USESHOWWINDOW
si.wShowWindow = 3# SW_MAXIMIZE

See the ShowWindow documentation for the list of values. AFAIK there is no named constant for them in the subprocess module.

The other window-related parameters of STARTUPINFO are not supported by popen at the moment. Most notably, none of dwX, dwY, dwXSize or dwYSize are supported.

As an alternative, you can check whether your implementation has a windows-specific extension, such as ActiveState's win32process.CreateProcess

Post a Comment for "Subprocess.popen Sets Size And Location Of The External Executed Programme?"