473,381 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,381 software developers and data experts.

Getting subprocesses to be hidden on Windows

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

Aug 27 '07 #1
11 5955
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

Aug 27 '07 #2
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

Aug 28 '07 #3
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


Aug 28 '07 #4
Which GUI toolkit are you using? Tkinter, wxPython, pyQt?
Primarily PyGTK, but I was hoping it wouldn't matter. I hope to be
able
to start the process as indicated in the original post from within my
test
tool and instruct the subprocess to be hidden (or minimized? would
that be easier?),
irrespective of what it was (it might be a Java GUI or anything for
all I care...)
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.
Thanks, that seemed to work.
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.
OK. If all else fails I might try that. But if there is a solution to
the original
problem it would be nice not to have to install VMWare everywhere for
convenient testing...

Geoff
Aug 28 '07 #5
On Aug 28, 8:59 am, geoffbache <geoff.ba...@pobox.comwrote:
Which GUI toolkit are you using? Tkinter, wxPython, pyQt?

Primarily PyGTK, but I was hoping it wouldn't matter. I hope to be
able
to start the process as indicated in the original post from within my
test
tool and instruct the subprocess to be hidden (or minimized? would
that be easier?),
irrespective of what it was (it might be a Java GUI or anything for
all I care...)
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.

Thanks, that seemed to work.
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.

OK. If all else fails I might try that. But if there is a solution to
the original
problem it would be nice not to have to install VMWare everywhere for
convenient testing...

Geoff
I did a quick google and found the following, which probably only
applies to Windows:

http://www.tech-recipes.com/windows_tips512.html

I know that with wxPython, you can tell it to whether or not to show
the frame. Maybe pyGTK has the same functionality? This link seems to
suggest that that maybe a valid option, but it doesn't detail how to
accomplish it:

http://www.daa.com.au/pipermail/pygt...st/000300.html

This might be better: http://linuxgazette.net/issue78/krishnakumar.html

Looks to me like you could just omit the "show" method. However, I
have never used that particular toolkit. When you run stuff hidden
like that, it can be difficult to kill them.

Mike

Aug 28 '07 #6
geoffbache wrote:
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
While I'm not entirely sure I understand what you want, I think you can
accomplish it by using win32CreateProcess instead of subprocess. You can run
the application minimized or perhaps in a REALLY small window. If you have
modal dialog boxes, I don't think you can do anything as they don't run in the
parent windows frame but rather outside (I could be wrong about this).

-Larry
Aug 28 '07 #7

OK, more background needed. I develop the TextTest tool which is a
generic test tool that starts tested applications from
the command line. The idea is that it can handle any system under test
at all, whatever language it's written in. Preferably
without requiring a bunch of changes to the tested code before
starting. I'd like to be able to pass some sort of flag to
ensure that the system under test *and everything it starts* remain
hidden.

I can do as you suggest in my PyGTK GUI, of course, but that's only
one system under test. A generic solution, if there
is one, would be much better. I felt like there ought to be one
because :

a) It's easy on UNIX and
b) I managed to hide the system under test fairly easily, just not its
child windows and dialogs.

Thanks for the help, anyway, it's another fallback if I can't find a
solution.

Aug 28 '07 #8
On 28 Aug, 18:18, Larry Bates <larry.ba...@websafe.comwrote:
geoffbache wrote:
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

While I'm not entirely sure I understand what you want, I think you can
accomplish it by using win32CreateProcess instead of subprocess. You can run
the application minimized or perhaps in a REALLY small window. If you have
modal dialog boxes, I don't think you can do anything as they don't run in the
parent windows frame but rather outside (I could be wrong about this).

-Larry
Hi Larry,

I don't know if that would help. I've tried running minimized from the
command line as
suggested by Mike and that has the same issue (child windows and
dialogs don't get minimized)
So the question is moving away from how to technically achieve this in
Python to whether
Windows even supports it...

Geoff

Aug 28 '07 #9

geoffbache wrote:
On 28 Aug, 18:18, Larry Bates <larry.ba...@websafe.comwrote:
>geoffbache wrote:
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

While I'm not entirely sure I understand what you want, I think you can
accomplish it by using win32CreateProcess instead of subprocess. You can run
the application minimized or perhaps in a REALLY small window. If you have
modal dialog boxes, I don't think you can do anything as they don't run in the
parent windows frame but rather outside (I could be wrong about this).

-Larry

Hi Larry,

I don't know if that would help. I've tried running minimized from the
command line as
suggested by Mike and that has the same issue (child windows and
dialogs don't get minimized)
So the question is moving away from how to technically achieve this in
Python to whether
Windows even supports it...

Geoff
You might want to look into running the tests on a separate desktop (or possibly
even a new window station).

Roger
Aug 29 '07 #10
On Aug 28, 1:13 pm, geoffbache <geoff.ba...@pobox.comwrote:
On 28 Aug, 18:18, Larry Bates <larry.ba...@websafe.comwrote:
geoffbache wrote:
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
While I'm not entirely sure I understand what you want, I think you can
accomplish it by using win32CreateProcess instead of subprocess. You can run
the application minimized or perhaps in a REALLY small window. If you have
modal dialog boxes, I don't think you can do anything as they don't run in the
parent windows frame but rather outside (I could be wrong about this).
-Larry

Hi Larry,

I don't know if that would help. I've tried running minimized from the
command line as
suggested by Mike and that has the same issue (child windows and
dialogs don't get minimized)
So the question is moving away from how to technically achieve this in
Python to whether
Windows even supports it...

Geoff
I just discovered Tim Golden's recipe for running processes minimized:
http://tgolden.sc.sabren.com/python/...cess-minimised

I haven't tested it, but his stuff usually works. However, it may have
the same issues with modal dialogs that my other suggestion had.

Mike

Aug 29 '07 #11
geoffbache wrote:
As part of my efforts to write a test tool that copes with GUIs
This is dead easy on UNIX with virtual displays like Xvfb.
Can someone shed any light if it's possible on Windows
Configure the virtual display first:
http://en.wikipedia.org/wiki/Virtual_desktop

Alternatively, run the process in a separate gui.
Terminal Server client is one way to do that.

[david]
Sep 3 '07 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jane Austine | last post by:
Running Python 2.3 on Win XP It seems like socket is working interdependently with subprocesses of the process which created socket. ------------------------------------ #the server side >>>...
2
by: Marcos | last post by:
Hi guys, I realise this question has been answered in one form or another many times before but I can't quite find the solution I need. I am trying to run multiple subprocesses from a python...
11
by: Ray Muforosky | last post by:
I have this: ------------ print "<FORM name=\"form3\" ACTION=\"cmdlog_rep.php\">\n"; print "<TD><INPUT TYPE=\"submit\" VALUE=\"Submit\"></TD>\n"; .. print "<INPUT type=\"HIDDEN\"...
2
by: Dave Kirby | last post by:
I am working on a network management program written in python that has multiple threads (typically 20+) spawning subprocesses which are used to communicate with other systems on the network. This...
5
by: Adam Clauss | last post by:
I have a webapp which consists of several different webforms. Basically: (1) view the contents of a database (2) one is to add a new entry (3) confirms the new entry. The third form, upon...
3
by: Dara Durum | last post by:
Hi ! Py2.4, Win32. I need to optimize a program that have a speciality: hash (MD5/SHA1) the file contents (many files). Now I do this in a simple python program, because (what a pity) the...
1
by: Gal Diskin | last post by:
Hi all, I'm writing a python program using threads to open several subprocesses concurrently (using module subprocess) and wait on them. I was wondering if there is a possibilty that a thread will...
0
by: shinichi81 | last post by:
1. I create a background Windows Explorer (by using CreateProcess() function with szCmdline = "explorer.exe /select,C:\" and hidden option). After that, from Desktop, right click "My Computer"...
0
by: =?Utf-8?B?aXdkdTE1?= | last post by:
hi, ive been working on a utility type app that would minimize all windows when the moue stays in a corner of the screen for more than 5 secodns....the only problem is getting all the VIEWABLE...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.