How does the process report the error? Does it create a file somewhere? Or does it show a dialog box? Does it write something to STDERR?
If the first, you only need a loop similar to this:
my $loopcount = 0;
1 while (! $process->Wait(1000) and ! -e $the_file and $loopcount++ <
+$timeout);
if ($loopcount >= $timeout) {
... fead up with waiting.
} elsif (-e $the_file) {
... it errored out
} else {
... it did its work
}
In the second case you should try it Win32::GuiTest's FindWindowLike() sees that error message box and then the loop will be similar. Just instead of -e $the_file you'll have something like FindWindowLike(0, "^My program error", undef). Plus maybe it'll be better if you find the main program window first and then only search among its children.
In the third case you'll have to
- store the STDIN, STDOUT and STDERR
- close them and open them to something else. Most probably you will want to pipe() to STDIN and open STDOUT and STDERR to a file (keep in mind that you cannot select() on anything but socket()s under Windows, AFAIK)
- start the process with INHERIT_HANDLES flag
- restore STDIN, STDOUT and STDERR
- print whatever you need to the pipe() leading to the program's STDIN (and hope the pipe is big enough and/or the program is reading)
- loop and test the files to that the process's STDOUT and STDERR write
I can go into more detail on the 2nd and 3rd if that is what you need.
Jenda@Krynicky.cz
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.