Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

script not working

by Raj07 (Initiate)
on Sep 25, 2009 at 04:15 UTC ( [id://797392]=perlquestion: print w/replies, xml ) Need Help??

Raj07 has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: script not working
by Urthas (Novice) on Sep 25, 2009 at 04:39 UTC

    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");
      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..
      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: perlquestion [id://797392]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-03-28 17:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found