harry34 has asked for the wisdom of the Perl Monks concerning the following question:

I have the following piece of code which opens a program called PLATON using a .ins file.
PLATON works by opening a dialog window and then number crunching with what ever is in the .ins file.
The dialog window remains open, PLATON will not move onto the next .ins file until the dialog window is shut manually. My question, is there a way of closing a window using perl commands ?

cheers harry
while ($m <=$blocks){ $ins_filename = "PMorph_$m.ins"; system ("platon -c $ins_filename"); #dialog window open $m++;

Replies are listed 'Best First'.
Re: Close window
by kodo (Hermit) on Aug 19, 2002 at 09:45 UTC
    Have a look at Win32::GuiTest. You can push Buttons of a dialog-window with it, which should do the job.

    giant
      so if I understand you correctly, when my dialog window opens I can get gui to automatically push the
      close button in the top right ?. Is it possible you can point me in the right direction as to what function or
      command I will need to use to achieve this.
      harry
        Hi Harry!

        Well it depends on what your dialog-box looks like. Usually you have an "okay" and "cancel" button or something. Then you could use the PushButton/PushChildButton-Function which works great. But of course you have to do a findwindow() etc before, read the POD for more info.
        Another way is to solve the problem via sendkeys(), you could send ALT+SPACE and then c to close it via the drop-down-menu.
        If all of this doesn't work, have a look at other Win32:: Modules, I currently don't remember the name but there is one which helps you to kill an app what should help also.

        giant
Re: Close window
by tommyw (Hermit) on Aug 20, 2002 at 08:56 UTC

    Does the platon command return before the window is closed? ie. does your perl program continue? Or is it that the second platon process simply refuses to start whilst there's another one in existance?

    My guess is that it's the former (which is quite antisocial of platon), and therefore the fix would be to fork platon off into a separate process. Your perl will then continue, and can close the stray window (by whatever method; hopefully Giant is correct ;-) or simply start a second (and third, fourth and fifth, etc.) subprocess going, until the user screams for mercy under all those windows...

    --
    Tommy
    Too stupid to live.
    Too stubborn to die.

      Basically on opening, platon displays in a dialog window what it is doing (number crunching). Once finished the perl program can only continue onto the next calculation if the dialog window is closed.
      I don't want to open lots of separate windows because I have 100's of files which go through the same calculation. Hence I need to close each new dialog window as it appears.
      I am new to perl, so could all suggestions please be simple as possible.
      thanks harry