Hi
Recently I have been posting (under my name and anonymously because I forgot to log in) a bout a problem I was having with detecting a popups. The good news I have cracked it. Many thanks for the Monks here whom helped me and specially to Ven'Tatsu and the pseudo code he provided me with which I based my solution on it.
As it is customary here, I am posting the full code for the benefit of all PRELovers.
Hmmmm, Maybe I shouldn't post this here (seekers of Perl wisdom) perhaps one of the Gods here will move to more appropriate area - Please do inform where these completed codes should go.
Thanks
Blackadder
#! c:/perl/bin
$|++;
AUTOLOAD;
require 5.008;
use strict;
use Win32;
use threads qw[yield]; #let us make threads
use threads::shared; # lets share vars between threads
use thread::Queue;
use POSIX qw [_exit];
use Win32::OLE qw[in with];
use Win32::GuiTest qw (:ALL :SW);
use vars qw/%data/;
use time::HiRes qw(sleep);
my $watcher = threads->create("Watcher");
my $job_done:shared=0;
system(); # Do what ever you like here and its popups will be monitore
+d.
$job_done = 1;
my $error = $watcher->join;
sub Watcher
{
my $watch_error = 0;
until ($job_done)
{
print "I am here\n";
my @windows = FindWindowLike(0,'GO');
for my $win (@windows)
{
print "Found $win =>". GetWindowText($win). "\n";
my @children = GetChildWindows($win);
for my $child (@children)
{
my $text = GetWindowText($child);
next if ($text =~ /^\xff/);
if ($text =~ /^OK$/i)
{
print "FOUND IT ==> Child : $child, Text : $text\n
+\n";
$watch_error = 1;
_exit 0;
}
}
}
sleep 1;
}
return $watch_error;
}
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.