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

Hi, I have this script;
#! c:\perl\bin $|++; use strict; use Win32; use Win32::GuiTest qw(:ALL :SW); use vars qw /%data/; $data{apps_list} = shift @ARGV; $data{host} = Win32::NodeName(); system (cls); print "\nThis machine is ". $data{host}; print "\n\nPath to apps list => ". $data{apps_list}."\n"; open (LST, "$data{apps_list}") || die "$! : File was not found\n"; chomp (@{$data{Go_scripts}} = <LST>); for my $item (@{$data{Go_scripts}}) { print "\n$item\n"; eval {system ($item); print "\n********* YOU ARE HERE ********\n"; my @windows = FindWindowLike(0, 'GO'); for my $win (@windows) { print "Found window $win with title '", GetWindowText($win), "'\ +n"; my @children = GetChildWindows($win); for my $child (@children) { my $text = GetWindowText($child); # next if ($text =~ /^\xff/); # you've found the icon #next if ($text =~ /^OK|Cancel|Abort|Retry|Ignore|Yes|No$/); # + you've found a button print "Found child $child with text '$text'\n"; } }}; Win32::AbortSystemShutdown($data{host}); print "\nDone\n"; }
The command system ($item); runs a software installation script. If the installation did not start for any reason a popup message box entitled ‘GO’ will appear indicating this. What I need to do is to detect that such window has appeared to indicate that the installation has failed. The Win32::GUITest code that follows the system($item) – which will do the detecting for me will only run after the system command has finished , and with it the Popup message will also disappear – doesn’t work. Is there away where I can get my GUITest code to monitor and detect the 'GO' popup when the system($item) being executed?

Thanks

Blackadder

Replies are listed 'Best First'.
Don't block
by PodMaster (Abbot) on May 14, 2004 at 11:21 UTC
    when you system, have it exit immediately (Win32::Process or cmd.exe /c command), then do your guitest polling ... example-ish

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      How do I exit immediatley?

      If I exit immediatly from system then will the pop up still appear?

      I even more lost now.

      Blackadder
        *cough*
        print "starting notepad, blocking, you must close it to continue$/"; system 'notepad.exe'; print "closed notepad, great$/starting notepad again, no blocking$/"; system qw[ cmd.exe /c start notepad ]; print "look, notepad still open, and I'm exiting$/";
        update: or in a more perl way system $^X,  -e => "exec(notepad)"

        MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
        I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
        ** The third rule of perl club is a statement of fact: pod is sexy.

        A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Win32::GUITest to run with System()
by Ven'Tatsu (Deacon) on May 14, 2004 at 14:02 UTC
    If you look in the eg/ directory of the Win32::GUITest package, it has a number of examples that can be useful. The author uses system("start notepad.exe");
    You'll need to get the source zip from the CPAN link or browse eg/ since AS doesn't include the eg/ direcoty in their PPMs.