使子进程在Windows上隐藏 [英] Getting subprocesses to be hidden on Windows

查看:76
本文介绍了使子进程在Windows上隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




作为我努力编写一个能够处理GUI的测试工具的一部分

很好,我正在努力建立我的方式可以在

Windows上启动GUI进程,而不会启动窗口。所以我试着隐藏窗口

如下:


info = subprocess.STARTUPINFO()

info.dwFlags | = subprocess.STARTF_USESHOWWINDOW

info.wShowWindow = subprocess.SW_HIDE


proc = subprocess.Popen(...,startupinfo = info)


这在某种程度上有效,但不能递归地工作。即如果

启动进程本身启动一个窗口,那第二个窗口将不会隐藏
。这甚至适用于应用程序中的对话框。所以

而不是很多窗口弹出我现在得到了很多无实体的

对话框出现,这是一个小小的改进,但并不多。


此外,某些进程(例如tkdiff)似乎忽略了完全隐藏

的指令。


这在UNIX上很容易实现使用Xvfb等虚拟显示器。如果有人可以在Windows上从python中获取任何光线吗?


问候,

Geoff Bache

解决方案

8月27日下午3:21,geoffbache< geoff.ba ... @ pobox.comwrote:





作为我努力编写一个能够处理GUI的测试工具的一部分

很好,我正在努力确定如何在不会​​启动窗口的Windows上启动GUI流程。所以我试着隐藏窗口

如下:


info = subprocess.STARTUPINFO()

info.dwFlags | = subprocess.STARTF_USESHOWWINDOW

info.wShowWindow = subprocess.SW_HIDE


proc = subprocess.Popen(...,startupinfo = info)


这在某种程度上有效,但不能递归地工作。即如果

启动进程本身启动一个窗口,那第二个窗口将不会隐藏
。这甚至适用于应用程序中的对话框。所以

而不是很多窗口弹出我现在得到了很多无实体的

对话框出现,这是一个小小的改进,但并不多。


此外,某些进程(例如tkdiff)似乎忽略了完全隐藏

的指令。


这在UNIX上很容易实现使用Xvfb等虚拟显示器。如果有人可以在Windows上从python中获取任何光线吗?


问候,

Geoff Bache



我很困惑。如果你不打算创建GUI,为什么要创建一个GUI?b $ b实际显示它?这不是GUI的重点吗?或者你正在谈论

关于弹出的命令窗口?


Mike


8月27日晚上11点28分,kyoso ... @ gmail.com写道:


8月27日下午3:21,geoffbache< geoff。 ba ... @ pobox.comwrote:




作为我努力编写一个能够处理GUI的测试工具

很好,我正在努力确定如何在

Windows上启动GUI过程,这将无法提升窗户。所以我试着隐藏窗口

如下:


info = subprocess.STARTUPINFO()

info.dwFlags | = subprocess.STARTF_USESHOWWINDOW

info.wShowWindow = subprocess.SW_HIDE


proc = subprocess。 Popen(...,startupinfo = info)


这在某种程度上起作用,但是递归不起作用。即如果

启动进程本身启动一个窗口,那第二个窗口将不会隐藏
。这甚至适用于应用程序中的对话框。所以

而不是很多窗口突然出现我现在得到了很多无实体的

对话框出现,这是一个小小的改进,但并不多。


此外,某些进程(例如tkdiff)似乎忽略了完全隐藏的指令



在使用Xvfb等虚拟显示的UNIX上,这很容易。如果有人可以在Windows上从python中删除任何光线吗?


问候,

Geoff Bache



我'我很困惑。如果你不打算创建GUI,为什么要创建一个GUI?b $ b实际显示它?这不是GUI的重点吗?或者你在谈论

关于弹出的命令窗口?


Mike



仅限于测试它的背景。如果我在我的

计算机上运行了很多GUI测试,我想要

测试的GUI保持隐藏状态,这样我仍然可以在
$ b $中使用我的电脑同时...


虽然你能告诉我如何停止弹出命令窗口

Windows

我我也很感激(虽然这不是原来的问题)。


Geoff


8月28日凌晨4:08,geoffbache< geoff.ba ... @ pobox.comwrote:


On 8月27日晚上11点28分,kyoso ... @ gmail.com写道:


8月27日下午3:21,geoffbache< geoff.ba。 .. @ pobox.comwrote:



< blockquote class =post_quotes>


作为我编写一个处理GUI的测试工具的一部分

很好,我正在努力确定如何在不会​​启动窗口的Windows上启动GUI流程。所以我试着隐藏窗口

如下:


info = subprocess.STARTUPINFO()

info.dwFlags | = subprocess.STARTF_USESHOWWINDOW

info.wShowWindow = subprocess.SW_HIDE


proc = subprocess.Popen(...,startupinfo = info)


这在某种程度上有效,但递归不起作用。即如果

启动进程本身启动一个窗口,那第二个窗口将不会隐藏
。这甚至适用于应用程序中的对话框。所以

而不是很多窗口突然出现我现在得到了很多无实体的

对话框出现,这是一个小小的改进,但并不多。


此外,某些进程(例如tkdiff)似乎忽略了指令

完全被隐藏。


在具有Xvfb等虚拟显示的UNIX上,这很容易。如果有人可以在Windows上从python中删除任何光线吗?


问候,

Geoff Bache


我很困惑。如果你不打算创建GUI,为什么要创建一个GUI?b $ b实际显示它?这不是GUI的重点吗?或者你在谈论弹出命令窗口的


Mike



仅在测试环境中。如果我在我的

计算机上运行了很多GUI测试,我想要

测试的GUI保持隐藏状态,这样我仍然可以在
$ b $中使用我的电脑同时...


虽然你能告诉我如何停止弹出命令窗口

Windows

我我也很感激(虽然这不是原来的问题)。


Geoff



您使用的是哪种GUI工具包? Tkinter,wxPython,pyQt?至于

在Windows上丢失命令窗口,我知道的最好的方法是将
的扩展名从* .py更改为

* .pyw。我很确定你可以压缩命令窗口,如果你是使用一个标志从命令行调用它们,但是我不记得

我最喜欢的标志。


在能够使用计算机的同时进行测试的一种方法是使用VMWare或某些软件来安装虚拟机类似的产品。我使用了

VMWare的免费软件来测试我的一些脚本,但是我听说过微软有一个免费的虚拟产品。一半不好。


迈克



Hi,

As part of my efforts to write a test tool that copes with GUIs
nicely, I''m trying to establish how I can start a GUI process on
Windows that will not bring up the window. So I try to hide the window
as follows:

info = subprocess.STARTUPINFO()
info.dwFlags |= subprocess.STARTF_USESHOWWINDOW
info.wShowWindow = subprocess.SW_HIDE

proc = subprocess.Popen(..., startupinfo=info)

This works, in a way, but doesn''t work recursively. I.e. if the
started process itself starts a window, that second window will not be
hidden. This even applies to dialog boxes within the application. So
instead of a lot of windows popping up I now get a lot of disembodied
dialogs appearing, which is a slight improvement but not much.

Also, certain processes (e.g. tkdiff) seem to ignore the directive to
be hidden altogether.

This is dead easy on UNIX with virtual displays like Xvfb. Can someone
shed any light if it''s possible on Windows from python?

Regards,
Geoff Bache

解决方案

On Aug 27, 3:21 pm, geoffbache <geoff.ba...@pobox.comwrote:

Hi,

As part of my efforts to write a test tool that copes with GUIs
nicely, I''m trying to establish how I can start a GUI process on
Windows that will not bring up the window. So I try to hide the window
as follows:

info = subprocess.STARTUPINFO()
info.dwFlags |= subprocess.STARTF_USESHOWWINDOW
info.wShowWindow = subprocess.SW_HIDE

proc = subprocess.Popen(..., startupinfo=info)

This works, in a way, but doesn''t work recursively. I.e. if the
started process itself starts a window, that second window will not be
hidden. This even applies to dialog boxes within the application. So
instead of a lot of windows popping up I now get a lot of disembodied
dialogs appearing, which is a slight improvement but not much.

Also, certain processes (e.g. tkdiff) seem to ignore the directive to
be hidden altogether.

This is dead easy on UNIX with virtual displays like Xvfb. Can someone
shed any light if it''s possible on Windows from python?

Regards,
Geoff Bache

I''m confused. Why would you create a GUI if you''re not going to
actually display it? Isn''t that the point of a GUI? Or are you talking
about the command window popping up?

Mike


On Aug 27, 11:28 pm, kyoso...@gmail.com wrote:

On Aug 27, 3:21 pm, geoffbache <geoff.ba...@pobox.comwrote:

Hi,

As part of my efforts to write a test tool that copes with GUIs
nicely, I''m trying to establish how I can start a GUI process on
Windows that will not bring up the window. So I try to hide the window
as follows:

info = subprocess.STARTUPINFO()
info.dwFlags |= subprocess.STARTF_USESHOWWINDOW
info.wShowWindow = subprocess.SW_HIDE

proc = subprocess.Popen(..., startupinfo=info)

This works, in a way, but doesn''t work recursively. I.e. if the
started process itself starts a window, that second window will not be
hidden. This even applies to dialog boxes within the application. So
instead of a lot of windows popping up I now get a lot of disembodied
dialogs appearing, which is a slight improvement but not much.

Also, certain processes (e.g. tkdiff) seem to ignore the directive to
be hidden altogether.

This is dead easy on UNIX with virtual displays like Xvfb. Can someone
shed any light if it''s possible on Windows from python?

Regards,
Geoff Bache


I''m confused. Why would you create a GUI if you''re not going to
actually display it? Isn''t that the point of a GUI? Or are you talking
about the command window popping up?

Mike

Only in the context of testing it. If I run lots of GUI tests on my
computer I want
the tested GUIs to remain hidden so I can still use my computer in the
meantime...

Though if you can tell me how to stop the command window popping up on
Windows
I''ll be grateful for that too (though it wasn''t the original
question).

Geoff


On Aug 28, 4:08 am, geoffbache <geoff.ba...@pobox.comwrote:

On Aug 27, 11:28 pm, kyoso...@gmail.com wrote:

On Aug 27, 3:21 pm, geoffbache <geoff.ba...@pobox.comwrote:

Hi,

As part of my efforts to write a test tool that copes with GUIs
nicely, I''m trying to establish how I can start a GUI process on
Windows that will not bring up the window. So I try to hide the window
as follows:

info = subprocess.STARTUPINFO()
info.dwFlags |= subprocess.STARTF_USESHOWWINDOW
info.wShowWindow = subprocess.SW_HIDE

proc = subprocess.Popen(..., startupinfo=info)

This works, in a way, but doesn''t work recursively. I.e. if the
started process itself starts a window, that second window will not be
hidden. This even applies to dialog boxes within the application. So
instead of a lot of windows popping up I now get a lot of disembodied
dialogs appearing, which is a slight improvement but not much.

Also, certain processes (e.g. tkdiff) seem to ignore the directive to
be hidden altogether.

This is dead easy on UNIX with virtual displays like Xvfb. Can someone
shed any light if it''s possible on Windows from python?

Regards,
Geoff Bache

I''m confused. Why would you create a GUI if you''re not going to
actually display it? Isn''t that the point of a GUI? Or are you talking
about the command window popping up?

Mike


Only in the context of testing it. If I run lots of GUI tests on my
computer I want
the tested GUIs to remain hidden so I can still use my computer in the
meantime...

Though if you can tell me how to stop the command window popping up on
Windows
I''ll be grateful for that too (though it wasn''t the original
question).

Geoff

Which GUI toolkit are you using? Tkinter, wxPython, pyQt? As for
losing the command window on Windows, the best way that I know of is
to just change the extension of the python file itself from *.py to
*.pyw . I''m pretty sure you can suppress command windows if you''re
calling them from the command line using a flag, but I can''t recall
the flag off the top of my head.

One way to test while still being able to use your computer is to
install a virtual machine with VMWare or some similar product. I use
VMWare''s free software for testing some of my scripts, but I''ve heard
that Microsoft''s got a free virtual product that isn''t half bad.

Mike



这篇关于使子进程在Windows上隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆