Loading ...
Sorry, an error occurred while loading the content.

Re: Another issue of Win32::Guitest hanging

Expand Messages
  • Piotr Kaluski
    It looks that Win32::MsgBox does not return until something is pressed. You should not have any problems finding a handle of any message box created by other
    Message 1 of 6 , Jul 13, 2005
    • 0 Attachment
      It looks that Win32::MsgBox does not return until something is
      pressed. You should not have any problems finding a handle of any
      message box created by other process.
      -Piotr

      --- In perlguitest@yahoogroups.com, "lmarlin" <lmarlin@y...> wrote:
      > This test script is similar to the Beach Bobby one of majingaa2z
      > posted this week:
      >
      > Script is:
      >
      >
      > use Win32;
      >
      > use Win32::GuiTest qw(:ALL);
      >
      > $Win32::GuiTest::debug = 1; # Set to "1" to enable verbose mode
      >
      > $result = Win32::MsgBox("something is DOWN",48,'test');
      >
      > my @windows = FindWindowLike(undef, 'test');
      >
      > if( !@windows )
      > {
      > die "Cannot find window with title/caption\n";
      > }
      > else
      > {
      > printf( "Window handle of application is %x\n", $windows[ 0 ] );
      > sleep 2;
      >
      > SetForegroundWindow($windows[0]);
      >
      >
      > my @children = GetChildWindows($windows[0]);
      > SetForegroundWindow( $children[ 0 ] );
      > SetFocus ( $children[ 0 ] );
      >
      > SendKeys("{ENTER}");
      > # PushButton ("OK");
      >
      >
      > }
      >
      > Environment: Windows XP SP2
      > Win32::GuiTest-1.50.3-ad
      >
      > Behavior:
      >
      > When run from the command prompt, (perl script.pl)
      > the message box displays but Perl never executes the FindWindowLike.
      >
      > If you click on the OK button in the message box, the
      FindWindowLike
      > fires (and fails) since the window it was supposed to find is gone.
      >
      > It makes no difference if you try:
      >
      > my @windows = FindWindowLike(0, 'test'); instead
      >
      > Is there an obvious goof here?
      >
      > or
      >
      > Any ideas about how to either find the handle for the message box
      > and set focus to it other than FindWindow or FindWindowLike?
      >
      > (Apologizing in advance if this is too trivial a question)?
    • Gábor Szabó
      ... To expand on what Piotr said. If you are doing this just to test Win32::GuiTest then write two scripts and run them in separate cmd windows: The first
      Message 2 of 6 , Jul 14, 2005
      • 0 Attachment
        On 7/14/05, Piotr Kaluski <pkaluski@...> wrote:
        > It looks that Win32::MsgBox does not return until something is
        > pressed. You should not have any problems finding a handle of any
        > message box created by other process.
        > -Piotr

        To expand on what Piotr said.

        If you are doing this just to test Win32::GuiTest then write two
        scripts and run them
        in separate cmd windows:

        The first script looks like this:

        use Win32;
        $result = Win32::MsgBox("something is DOWN",48,'test');
        print $result;

        the other script is the rest of the code you had
        Gabor
      • lmarlin
        Thanks - based on both of your suggestions (Gabor & Piotr) , I set up one script to run and pop the MsgBox and a second script to look for for the test
        Message 3 of 6 , Jul 14, 2005
        • 0 Attachment
          Thanks - based on both of your suggestions (Gabor & Piotr) , I set
          up one script to run and pop the MsgBox and a second script to look
          for for the "test" MsgBox and, if found, press the OK button. This
          works just as you and Piotr suggested.

          The finished scripts are below.

          Script 1:
          ==========
          use Win32;
          $result = Win32::MsgBox("something is DOWN",48,'test');
          print $result;



          Script 2:
          ===========
          use Win32;
          use Win32::GuiTest qw(:ALL);
          $Win32::GuiTest::debug = 0; # Set to "1" if verbose mode desired

          while(1)
          {

          my @windows = FindWindowLike(undef, 'test');
          if( !@windows )
          {
          # die "Cannot find window with title/caption\n";
          sleep 2;
          #
          # sleep, wait for "test" window to appear, then pounce
          #
          }
          else
          {
          printf( "Window handle of application is %x\n", $windows[ 0 ] );
          sleep 2;
          SetForegroundWindow($windows[0]);
          PushButton ("OK");
          }
          } # end while

          Lee
          "When the height is won, then there is ease" - Aeschylus

          --- In perlguitest@yahoogroups.com, Gábor Szabó <szabgab@g...> wrote:
          > On 7/14/05, Piotr Kaluski <pkaluski@p...> wrote:
          > > It looks that Win32::MsgBox does not return until something is
          > > pressed. You should not have any problems finding a handle of any
          > > message box created by other process.
          > > -Piotr
          >
          > To expand on what Piotr said.
          >
          > If you are doing this just to test Win32::GuiTest then write two
          > scripts and run them
          > in separate cmd windows:
          >
          > The first script looks like this:
          >
          > use Win32;
          > $result = Win32::MsgBox("something is DOWN",48,'test');
          > print $result;
          >
          > the other script is the rest of the code you had
          > Gabor
        • Dennis K. Paulsen
          Yeah, that s it. Just the way the Windows message box works. There are several ways around this (spawning external script, write custom message box routine,
          Message 4 of 6 , Aug 3 3:33 PM
          • 0 Attachment
            Yeah, that's it. Just the way the Windows message box works. There
            are several ways around this (spawning external script, write custom
            message box routine, etc, etc.), but beyond the scope of this forum
            and the time I have lately. :-(

            Regards.

            --- In perlguitest@yahoogroups.com, "Piotr Kaluski" <pkaluski@p...>
            wrote:
            > It looks that Win32::MsgBox does not return until something is
            > pressed. You should not have any problems finding a handle of any
            > message box created by other process.
            > -Piotr
            >
            > --- In perlguitest@yahoogroups.com, "lmarlin" <lmarlin@y...> wrote:
            > > This test script is similar to the Beach Bobby one of majingaa2z
            > > posted this week:
            > >
            > > Script is:
            > >
            > >
            > > use Win32;
            > >
            > > use Win32::GuiTest qw(:ALL);
            > >
            > > $Win32::GuiTest::debug = 1; # Set to "1" to enable verbose mode
            > >
            > > $result = Win32::MsgBox("something is DOWN",48,'test');
            > >
            > > my @windows = FindWindowLike(undef, 'test');
            > >
            > > if( !@windows )
            > > {
            > > die "Cannot find window with title/caption\n";
            > > }
            > > else
            > > {
            > > printf( "Window handle of application is %x\n", $windows[
            0 ] );
            > > sleep 2;
            > >
            > > SetForegroundWindow($windows[0]);
            > >
            > >
            > > my @children = GetChildWindows($windows[0]);
            > > SetForegroundWindow( $children[ 0 ] );
            > > SetFocus ( $children[ 0 ] );
            > >
            > > SendKeys("{ENTER}");
            > > # PushButton ("OK");
            > >
            > >
            > > }
            > >
            > > Environment: Windows XP SP2
            > > Win32::GuiTest-1.50.3-ad
            > >
            > > Behavior:
            > >
            > > When run from the command prompt, (perl script.pl)
            > > the message box displays but Perl never executes the
            FindWindowLike.
            > >
            > > If you click on the OK button in the message box, the
            > FindWindowLike
            > > fires (and fails) since the window it was supposed to find is
            gone.
            > >
            > > It makes no difference if you try:
            > >
            > > my @windows = FindWindowLike(0, 'test'); instead
            > >
            > > Is there an obvious goof here?
            > >
            > > or
            > >
            > > Any ideas about how to either find the handle for the message
            box
            > > and set focus to it other than FindWindow or FindWindowLike?
            > >
            > > (Apologizing in advance if this is too trivial a question)?
          • Lee Marlin
            Thanks for the confirmation and all the great code examples. I had a similar problem with SaveAs and invented the following companion process to get around
            Message 5 of 6 , Aug 3 9:50 PM
            • 0 Attachment
              Thanks for the confirmation and all the great code examples. I had a similar problem with "SaveAs" and invented the following companion process to get around it.

              The original application starts this code prior to performing a SaveAs for an HTML document. Worked great.

              Lee
              # =========================================================
              use Win32::GuiTest qw ( :ALL :SW );

              my $messageClass = "^#32770";
              my $SaveHTML = "^Save HTML Document";
              @SaveAswins = FindWindowLike( 0, $SaveHTML, $messageClass );
              die unless scalar @SaveAswins == 1 && IsWindow($SaveAswins[0]);
              print "FindWindowLike SaveAswins - found " . @SaveAswins . " window(s).\n";
              print "SaveAswins=$SaveAswins[0]\n";

              SetForegroundWindow($SaveAswins[0]);
              Win32::GuiTest::SendKeys("{TAB}{TAB}{ENTER}");
              Win32::GuiTest::SendKeys("{ENTER}");



              "Dennis K. Paulsen" <ctrondlpaulsden@...> wrote:

              Yeah, that's it. Just the way the Windows message box works. There
              are several ways around this (spawning external script, write custom
              message box routine, etc, etc.), but beyond the scope of this forum
              and the time I have lately. :-(

              Regards.

              --- In perlguitest@yahoogroups.com, "Piotr Kaluski" <pkaluski@p...>
              wrote:
              > It looks that Win32::MsgBox does not return until something is
              > pressed. You should not have any problems finding a handle of any
              > message box created by other process.
              > -Piotr
              >
              > --- In perlguitest@yahoogroups.com, "lmarlin" <lmarlin@y...> wrote:
              > > This test script is similar to the Beach Bobby one of majingaa2z
              > > posted this week:
              > >
              > > Script is:
              > >
              > >
              > > use Win32;
              > >
              > > use Win32::GuiTest qw(:ALL);
              > >
              > > $Win32::GuiTest::debug = 1; # Set to "1" to enable verbose mode
              > >
              > > $result = Win32::MsgBox("something is DOWN",48,'test');
              > >
              > > my @windows = FindWindowLike(undef, 'test');
              > >
              > > if( !@windows )
              > > {
              > > die "Cannot find window with title/caption\n";
              > > }
              > > else
              > > {
              > > printf( "Window handle of application is %x\n", $windows[
              0 ] );
              > > sleep 2;
              > >
              > > SetForegroundWindow($windows[0]);
              > >
              > >
              > > my @children = GetChildWindows($windows[0]);
              > > SetForegroundWindow( $children[ 0 ] );
              > > SetFocus ( $children[ 0 ] );
              > >
              > > SendKeys("{ENTER}");
              > > # PushButton ("OK");
              > >
              > >
              > > }
              > >
              > > Environment: Windows XP SP2
              > > Win32::GuiTest-1.50.3-ad
              > >
              > > Behavior:
              > >
              > > When run from the command prompt, (perl script.pl)
              > > the message box displays but Perl never executes the
              FindWindowLike.
              > >
              > > If you click on the OK button in the message box, the
              > FindWindowLike
              > > fires (and fails) since the window it was supposed to find is
              gone.
              > >
              > > It makes no difference if you try:
              > >
              > > my @windows = FindWindowLike(0, 'test'); instead
              > >
              > > Is there an obvious goof here?
              > >
              > > or
              > >
              > > Any ideas about how to either find the handle for the message
              box
              > > and set focus to it other than FindWindow or FindWindowLike?
              > >
              > > (Apologizing in advance if this is too trivial a question)?





              ---------------------------------
              YAHOO! GROUPS LINKS


              Visit your group "perlguitest" on the web.

              To unsubscribe from this group, send an email to:
              perlguitest-unsubscribe@yahoogroups.com

              Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


              ---------------------------------



              __________________________________________________
              Do You Yahoo!?
              Tired of spam? Yahoo! Mail has the best spam protection around
              http://mail.yahoo.com

              [Non-text portions of this message have been removed]
            Your message has been successfully submitted and would be delivered to recipients shortly.