Getting subprocesses to be hidden on Windows

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • geoffbache

    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.STAR TUPINFO()
    info.dwFlags |= subprocess.STAR TF_USESHOWWINDO W
    info.wShowWindo w = subprocess.SW_H IDE

    proc = subprocess.Pope n(..., startupinfo=inf o)

    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

  • kyosohma@gmail.com

    #2
    Re: Getting subprocesses to be hidden on Windows

    On Aug 27, 3:21 pm, geoffbache <geoff.ba...@po box.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.STAR TUPINFO()
    info.dwFlags |= subprocess.STAR TF_USESHOWWINDO W
    info.wShowWindo w = subprocess.SW_H IDE
    >
    proc = subprocess.Pope n(..., startupinfo=inf o)
    >
    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

    Comment

    • geoffbache

      #3
      Re: Getting subprocesses to be hidden on Windows

      On Aug 27, 11:28 pm, kyoso...@gmail. com wrote:
      On Aug 27, 3:21 pm, geoffbache <geoff.ba...@po box.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.STAR TUPINFO()
      info.dwFlags |= subprocess.STAR TF_USESHOWWINDO W
      info.wShowWindo w = subprocess.SW_H IDE
      >
      proc = subprocess.Pope n(..., startupinfo=inf o)
      >
      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

      Comment

      • kyosohma@gmail.com

        #4
        Re: Getting subprocesses to be hidden on Windows

        On Aug 28, 4:08 am, geoffbache <geoff.ba...@po box.comwrote:
        On Aug 27, 11:28 pm, kyoso...@gmail. com wrote:
        >
        >
        >
        On Aug 27, 3:21 pm, geoffbache <geoff.ba...@po box.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.STAR TUPINFO()
        info.dwFlags |= subprocess.STAR TF_USESHOWWINDO W
        info.wShowWindo w = subprocess.SW_H IDE
        >
        proc = subprocess.Pope n(..., startupinfo=inf o)
        >
        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




        Comment

        • geoffbache

          #5
          Re: Getting subprocesses to be hidden on Windows

          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


          Comment

          • kyosohma@gmail.com

            #6
            Re: Getting subprocesses to be hidden on Windows

            On Aug 28, 8:59 am, geoffbache <geoff.ba...@po box.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:



            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:



            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

            Comment

            • Larry Bates

              #7
              Re: Getting subprocesses to be hidden on Windows

              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.STAR TUPINFO()
              info.dwFlags |= subprocess.STAR TF_USESHOWWINDO W
              info.wShowWindo w = subprocess.SW_H IDE
              >
              proc = subprocess.Pope n(..., startupinfo=inf o)
              >
              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 win32CreateProc ess 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

              Comment

              • geoffbache

                #8
                Re: Getting subprocesses to be hidden on Windows


                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.

                Comment

                • geoffbache

                  #9
                  Re: Getting subprocesses to be hidden on Windows

                  On 28 Aug, 18:18, Larry Bates <larry.ba...@we bsafe.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.STAR TUPINFO()
                  info.dwFlags |= subprocess.STAR TF_USESHOWWINDO W
                  info.wShowWindo w = subprocess.SW_H IDE
                  >
                  proc = subprocess.Pope n(..., startupinfo=inf o)
                  >
                  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 win32CreateProc ess 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

                  Comment

                  • Roger Upole

                    #10
                    Re: Getting subprocesses to be hidden on Windows


                    geoffbache wrote:
                    On 28 Aug, 18:18, Larry Bates <larry.ba...@we bsafe.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.STAR TUPINFO()
                    info.dwFlags |= subprocess.STAR TF_USESHOWWINDO W
                    info.wShowWindo w = subprocess.SW_H IDE
                    >>
                    proc = subprocess.Pope n(..., startupinfo=inf o)
                    >>
                    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 win32CreateProc ess 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


                    Comment

                    • kyosohma@gmail.com

                      #11
                      Re: Getting subprocesses to be hidden on Windows

                      On Aug 28, 1:13 pm, geoffbache <geoff.ba...@po box.comwrote:
                      On 28 Aug, 18:18, Larry Bates <larry.ba...@we bsafe.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.STAR TUPINFO()
                      info.dwFlags |= subprocess.STAR TF_USESHOWWINDO W
                      info.wShowWindo w = subprocess.SW_H IDE
                      >
                      proc = subprocess.Pope n(..., startupinfo=inf o)
                      >
                      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 win32CreateProc ess 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:


                      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

                      Comment

                      • [david]

                        #12
                        Re: Getting subprocesses to be hidden on Windows

                        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:


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

                        [david]

                        Comment

                        Working...