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:
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: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; }
SetForegroundWindow(WaitFor("Some Title"));
Update: Remember to keep the parentheses around the $win in the loop, because FindWindowLike returns a list.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Win32::GuiTest waiting for a window
by primus (Scribe) on Jan 12, 2004 at 19:27 UTC |
In Section
Seekers of Perl Wisdom