Oh my good Lord, format that code by wrapping it in html code blocks:
use Win32::GuiTest qw/:ALL/;
$Win32::GuiTest::debug = 1;
my $fgWindow1= 0; # Foreground Window
system("c:\\MyApp\\abcd.exe");
$fgWindow1=WaitWindowLike( 0 , "^MyApp Administration");
SetForegroundWindow($fgWindow1);
my @Mwnd= FindWindowLike(0 , "^MyApp Administration");
SetForegroundWindow( $Mwnd 0 );
if( not @Mwnd ) {
printf( "Cannot find window with title/caption MyApp Administratio
+n \n");
}
else {
printf( "Window handle of MyApp application is %x \n", $Mwnd 0 );
}
if(IsWindowVisible($Mwnd 0 )) {
printf("Application launched successfully \n");
}
else {
printf("Application launching is failed \n");
}
Anyways, if nothing else you are using $Mwnd 0 when you almost certainly mean $Mwnd[0]. I also see if( not @Mwnd ) instead of if(! @Mwnd), although it's pointless to check this after you've already attempted to use the first element in the call to SetForegroundWindow(). You are also using a superfluous call to printf when print will do just fine:
print( "Cannot find window with title/caption MyApp Administration \n"); |