http://qs321.pair.com?node_id=320724


in reply to Win32::GuiTest waiting for a window

You're right, you do need to sleep. Here's what I use in one of my programs to wait for a window:

sub WaitFor { my $win; my $title = shift; while (!defined $win) { select(undef,undef,undef,0.1); # sleep for 1/10th of a second ($win) = FindWindowLike(0, $title); } return $win; }
This sub takes the window title as a parameter and then just sleeps until that window appears. It doesn't set it to the active window, but you can do that with something like this:
SetForegroundWindow(WaitFor("Some Title"));

Update: Remember to keep the parentheses around the $win in the loop, because FindWindowLike returns a list.

kelan


Perl6 Grammar Student

Replies are listed 'Best First'.
Re: Re: Win32::GuiTest waiting for a window
by primus (Scribe) on Jan 12, 2004 at 19:27 UTC
    thanks! worked like a charm