in reply to Confirm an application opens (win32)
That seems like a useful subroutine.
But I'm curious. Since:
if( $title =~ /$searchString/ ) { $uiFound = 1 } last if ( $uiFound >= 1 );
will always break out of the loop when there's a match, couldn't you refactor the code (assuming that the rest of the logic works) to:?
sub ConfirmUI { my $searchString = shift; my $uiFound = 0; for (FindWindowLike()) { my $title = GetWindowText($_); next unless ( $title ); if( $title =~ /$searchString/ ) { $uiFound = 1; last; } } return( $uiFound ); }
And for that matter, to:
sub ConfirmUI { my $searchString = shift; for (FindWindowLike()) { my $title = GetWindowText($_); if ($title and $title =~ /$searchString/) { return 1; } } return 0; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Confirm an application opens (win32)
by bobf (Monsignor) on Aug 14, 2007 at 02:32 UTC | |
|
Re^2: Confirm an application opens (win32)
by technojosh (Priest) on Aug 13, 2007 at 21:48 UTC |