Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: script not working

by Urthas (Novice)
on Sep 25, 2009 at 04:39 UTC ( [id://797397]=note: print w/replies, xml ) Need Help??


in reply to script not working

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");

Replies are listed 'Best First'.
Re^2: script not working
by almut (Canon) on Sep 25, 2009 at 08:42 UTC
    you are using $Mwnd 0 when you almost certainly mean $Mwnd[0]

    This is just an artifact of PerlMonks turning things in brackets like [0] into links (when the brackets are found outside of <code> tags, and aren't HTML-escaped, of course).  If you click on the xml link at the top of the node, you'll see that the brackets are in fact there in the original input.

    (In cases of misformatted nodes, I usually just cut-n-paste the respective section out of that XML doctext from the browser into my editor. This way I also get the original linebreaks, without the need for manual reformatting. — But this is not meant as an invitation for people to no longer care about proper formatting/tagging... Please!! ;)

      Sorry friends..i shouldn't have submitted the post as it is...it was done mistakenly..
Re^2: script not working
by jevaly (Sexton) on Sep 25, 2009 at 09:03 UTC
    also the hash %x is used in:

    printf( "Window handle of MyApp application is %x \n", $Mwnd 0 );

    but is nowhere declared or initizialized in the application.
    use strict might be of great use to the user.
      also the hash %x is used
      Actually, %x in this context is not referring to a hash. It is the printf format directive to print as (unsigned) hexadecimal. See the man page for printf.
      I have tried all the ways suggested by you, but still the window hanlde is displayed as 0.I a m using Perl Express 2.5 IDE for my scripting.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://797397]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-03-28 16:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found