Getting subprocesses to be hidden on Windows

geoffbache geoff.bache at pobox.com
Mon Aug 27 16:21:16 EDT 2007


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




More information about the Python-list mailing list