subprocess.Popen 设置外部执行程序的大小和位置? [英] subprocess.Popen sets size and location of the external executed programme?
问题描述
我想通过 subprocess.Popen 从 python 执行一个外部程序.我想知道是否可以为通过命令执行的外部程序设置窗口的大小和位置?
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 programme that is executed via the command?
推荐答案
我假设 Windows 有这样的问题?
I assume Windows for such a question?
您可以使用 startupinfo
popen 的参数.
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
请参阅ShowWindow
值列表的文档.AFAIK 在子流程模块中没有命名常量.
See the ShowWindow
documentation for the list of values. AFAIK there is no named constant for them in the subprocess module.
STARTUPINFO
的其他窗口相关参数暂不支持 popen.最值得注意的是,dwX
、dwY
、dwXSize
或 dwYSize
均不受支持.
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.
作为替代方案,您可以检查您的实现是否具有特定于 Windows 的扩展,例如 ActiveState 的 win32process.CreateProcess
As an alternative, you can check whether your implementation has a windows-specific extension, such as ActiveState's win32process.CreateProcess
这篇关于subprocess.Popen 设置外部执行程序的大小和位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!