Esteemed Monks,

I need your help and guidance please,....

I am using ‘system()’ on WinXP to run list of batch files – that installs software - and using GUITest to check if the execution of those batch files were successful, like so;
$|++; use strict; use Win32; use Win32::GuiTest qw(:ALL :SW); use vars qw /%data/; system (cls); $data{apps_list} = shift @ARGV; $data{host} = Win32::NodeName(); 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}}) { System ($item); Print "Testing => $item\n"; # # some code needs to be here to detect the popup! # Win32::AbortSystemShutdown($data{host}); }
Only if the execution of this batch file was unsuccessful, then a popup window appears indicating the failure, otherwise no popup windows will appear. Also, those popups do not remain on the screen, they have a time out value of few seconds and they disappear soon after.

Basically, I am trying to detect those pop ups using this bit of code which I test and it works fine,
While (1) { my @windows = FindWindowLike(0, 'MYPOPUP'); 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 + print "Found child $child with text '$text'\n" if ($text =~ /^ +OK$/)}}}
However my problem is this, If I insert the above GUItest code after the System( ) command, then it will only run after System() has completed its excution and by then if there were any popups, then they would have disappeared.

A suggestion was made is to exit system() after starting the batch file and then running the above code. But will not help because there is no telling when these popups will appear – it could happen as soon as the batch file has ran or after few seconds. And importantly one batch file must complete its execution before starting another.

Oh, some of those batch file will attemp to restart the local machine so I need to prevent that.

What I need to do is to have the above GUITestcode running in tandem with the system ($batch) command. i.e. as the system() begins running a batch file from the list then the GUItest should start monitoring for any popup connected to that particular batch file. and Only move on to the next batch file in the list when the running of the current batch file has completed or a popup was detected.

I am not sure how I can achieve this! Do I need to use multi threading? Can I get system() to run to processes concurrently? Alternatively, how can I exit off the while loop once the batch file has completed its run?

Can some one please help me out here....That wil be very highly appreaciated,....Indeed.

Thank you very much in advance.

In reply to GUITest to test GUI by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.