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

Re: [perlguitest] PushChildButton Not actually firing the event handler related to the button

Expand Messages
  • Santosh Kumar
    Param, Try using PushButton instead of PushChildButton. Check this code snippet to click Next button, it works with better consistency (I never faced any
    Message 1 of 5 , Aug 22, 2006
    • 0 Attachment
      Param,

      Try using PushButton instead of PushChildButton.
      Check this code snippet to click Next button, it works with better consistency (I never faced any issue) with the same "Add Hardware Wizard".

      my $Window = 'Add hardware Wizard';
      my @WHdls = FindWindowLike(0, $Window, "" );
      my $hwnd = $WHdls[0]; # Window handle
      SetForegroundWindow( $hwnd ); # Get Add Hardware Wizard to front and active.
      my $result = PushButton( '&Next', '0.5' ); #Click Next with 0.5 seconds of delay.
      #Now wait for next window, or what ever you want.

      I suppose, issue you are facing could be due to parent window loosing focus / active status while you are sending the PushChildButton action.

      Regards,
      ~Santosh



      ----- Original Message -----
      From: paramsan1234
      To: perlguitest@yahoogroups.com
      Sent: Tuesday, August 22, 2006 11:51 AM
      Subject: [perlguitest] PushChildButton Not actually firing the event handler related to the button


      Hi all!

      My situation:
      I am new to perl. I use Win32::GuiTest to achieve some screenscaping
      for windows (!!!) popping up "Add New Hardware Wizard".

      Code Snippet:

      use Win32::GuiTest qw(WaitWindowLike PushChildButton SendKeys)

      $Win32::GuiTest::debug = 1; # Set Debugging

      $WinHandle = WaitWindowLike(undef, "^Add New Hardware", "", "", 1200);
      # Set a timeout for 1200 seconds

      PushChildButton($WinHandle, "Next >", 0.25);
      # Set delay of 250ms for debugging

      # Don't worry about the syntax or compile errors in the code, this
      # should serve as a pseudo code to actually what I am doing since
      # screen-scraping, which is why I am using Win32::GuiTest is my last
      # alternative though I know Win32::GuiTest is extremely useful
      # for thousands of windows errands/problems

      Problem:
      The code is as complex as it gets above (an irony, acutally it's
      simple though!). However the real issue is that sometimes the "Next >"
      button gets pushed and sometimes not. So I tried some detailed
      checking and figured out that PushChildButton is returning a true
      value (1) means that it did it's work though I can't actually see it
      press the button and neither does the window proceeds to the next step.
      However, I want a bit consistency in my program and want to make sure
      that it should work for the 99 % of cases (getting realistic of some
      other conditions)

      I haven't seen the bug reports in detail though but I am not sure why
      my code will be doing this. It seems as if something is interfering
      between the time the PushChildButton's action is sent and the event
      handler is kicked off. While, I have seen it work and not work in the
      same conditions? Or this might not be a bug at all but some windows thing?

      If any of you went throught the same problem, please help me explain
      to as why is this happening and how can I make sure that the Next
      button is pressed and the correct event takes place?

      Future Effort:
      The next part I am going to try is to put the child button (window) id
      instead of the text and;
      try using sendMessage(...) somehow?

      Fine Print:
      If any of you had any similar threads posted before, please feel free
      to redirect me to the correct place and if anything is not clear, I
      should try to correct my programming english considering the fact that
      I have just dived into the ocean and is still swimming near the shore.

      Thanking all,
      Param





      [Non-text portions of this message have been removed]
    • paramsan1234
      PushButton does not works totally though, but PushChildButton works now. I don t know what the & does to &Next ? So the text on the next button is like
      Message 2 of 5 , Aug 22, 2006
      • 0 Attachment
        PushButton does not works totally though, but PushChildButton works
        now. I don't know what the '&' does to '&Next'?
        So the text on the next button is like "Next >" while on the finish
        button is "Finish." As you suggested I used '&Next' and the script
        worked fine. Now if I use '&Finish' nothing happens but if I
        use 'Finish' the button gets pushed. What is it doing behind the
        scenes?

        [If you are wondering where do I use them, I use them right
        PushChildButton($windowHandle, '&Next', '0.25');
        or
        PushChildButton($windowHandle, 'Finish', '0.25');

        And Thanks for the suggestion of '&Next' Its working (for now
        atleast).


        --- In perlguitest@yahoogroups.com, "Santosh Kumar"
        <kadlisantosh@...> wrote:
        >
        > Param,
        >
        > Try using PushButton instead of PushChildButton.
        > Check this code snippet to click Next button, it works with better
        consistency (I never faced any issue) with the same "Add Hardware
        Wizard".
        >
        > my $Window = 'Add hardware Wizard';
        > my @WHdls = FindWindowLike(0, $Window, "" );
        > my $hwnd = $WHdls[0]; # Window handle
        > SetForegroundWindow( $hwnd ); # Get Add Hardware Wizard to front
        and active.
        > my $result = PushButton( '&Next', '0.5' ); #Click Next with 0.5
        seconds of delay.
        > #Now wait for next window, or what ever you want.
        >
        > I suppose, issue you are facing could be due to parent window
        loosing focus / active status while you are sending the
        PushChildButton action.
        >
        > Regards,
        > ~Santosh
        >
        >
        >
        > ----- Original Message -----
        > From: paramsan1234
        > To: perlguitest@yahoogroups.com
        > Sent: Tuesday, August 22, 2006 11:51 AM
        > Subject: [perlguitest] PushChildButton Not actually firing the
        event handler related to the button
        >
        >
        > Hi all!
        >
        > My situation:
        > I am new to perl. I use Win32::GuiTest to achieve some
        screenscaping
        > for windows (!!!) popping up "Add New Hardware Wizard".
        >
        > Code Snippet:
        >
        > use Win32::GuiTest qw(WaitWindowLike PushChildButton SendKeys)
        >
        > $Win32::GuiTest::debug = 1; # Set Debugging
        >
        > $WinHandle = WaitWindowLike(undef, "^Add New Hardware", "", "",
        1200);
        > # Set a timeout for 1200 seconds
        >
        > PushChildButton($WinHandle, "Next >", 0.25);
        > # Set delay of 250ms for debugging
        >
        > # Don't worry about the syntax or compile errors in the code,
        this
        > # should serve as a pseudo code to actually what I am doing since
        > # screen-scraping, which is why I am using Win32::GuiTest is my
        last
        > # alternative though I know Win32::GuiTest is extremely useful
        > # for thousands of windows errands/problems
        >
        > Problem:
        > The code is as complex as it gets above (an irony, acutally it's
        > simple though!). However the real issue is that sometimes
        the "Next >"
        > button gets pushed and sometimes not. So I tried some detailed
        > checking and figured out that PushChildButton is returning a true
        > value (1) means that it did it's work though I can't actually see
        it
        > press the button and neither does the window proceeds to the next
        step.
        > However, I want a bit consistency in my program and want to make
        sure
        > that it should work for the 99 % of cases (getting realistic of
        some
        > other conditions)
        >
        > I haven't seen the bug reports in detail though but I am not sure
        why
        > my code will be doing this. It seems as if something is
        interfering
        > between the time the PushChildButton's action is sent and the
        event
        > handler is kicked off. While, I have seen it work and not work in
        the
        > same conditions? Or this might not be a bug at all but some
        windows thing?
        >
        > If any of you went throught the same problem, please help me
        explain
        > to as why is this happening and how can I make sure that the Next
        > button is pressed and the correct event takes place?
        >
        > Future Effort:
        > The next part I am going to try is to put the child button
        (window) id
        > instead of the text and;
        > try using sendMessage(...) somehow?
        >
        > Fine Print:
        > If any of you had any similar threads posted before, please feel
        free
        > to redirect me to the correct place and if anything is not clear,
        I
        > should try to correct my programming english considering the fact
        that
        > I have just dived into the ocean and is still swimming near the
        shore.
        >
        > Thanking all,
        > Param
        >
        >
        >
        >
        >
        > [Non-text portions of this message have been removed]
        >
      • Girish
        Hi Param, To understand/confirm the exact label/caption of the button use a spy tool or try below; ... my @childwnds = GetChildWindows($MainWin[0]); # Where
        Message 3 of 5 , Aug 23, 2006
        • 0 Attachment
          Hi Param,

          To understand/confirm the exact label/caption of the button use a spy tool
          or try below;
          -------------------------------------------------------------------------------------------------------------
          my @childwnds = GetChildWindows($MainWin[0]);
          # Where $MainWin[0] is the window containing Next and Finish buttons
          foreach my $CWinHanlde (@childwnds) {
          my $ChildWinName = GetWindowText($CWinHanlde);
          print "$CWinHanlde --> $ChildWinName \n";
          }
          -------------------------------------------------------------------------------------------------------------
          Hope it helps u

          Thanks
          -Girish.

          On 8/22/06, paramsan1234 <paramsan1234@...> wrote:
          >
          > PushButton does not works totally though, but PushChildButton works
          > now. I don't know what the '&' does to '&Next'?
          > So the text on the next button is like "Next >" while on the finish
          > button is "Finish." As you suggested I used '&Next' and the script
          > worked fine. Now if I use '&Finish' nothing happens but if I
          > use 'Finish' the button gets pushed. What is it doing behind the
          > scenes?
          >
          > [If you are wondering where do I use them, I use them right
          > PushChildButton($windowHandle, '&Next', '0.25');
          > or
          > PushChildButton($windowHandle, 'Finish', '0.25');
          >
          > And Thanks for the suggestion of '&Next' Its working (for now
          > atleast).
          >
          >
          > --- In perlguitest@yahoogroups.com, "Santosh Kumar"
          > <kadlisantosh@...> wrote:
          > >
          > > Param,
          > >
          > > Try using PushButton instead of PushChildButton.
          > > Check this code snippet to click Next button, it works with better
          > consistency (I never faced any issue) with the same "Add Hardware
          > Wizard".
          > >
          > > my $Window = 'Add hardware Wizard';
          > > my @WHdls = FindWindowLike(0, $Window, "" );
          > > my $hwnd = $WHdls[0]; # Window handle
          > > SetForegroundWindow( $hwnd ); # Get Add Hardware Wizard to front
          > and active.
          > > my $result = PushButton( '&Next', '0.5' ); #Click Next with 0.5
          > seconds of delay.
          > > #Now wait for next window, or what ever you want.
          > >
          > > I suppose, issue you are facing could be due to parent window
          > loosing focus / active status while you are sending the
          > PushChildButton action.
          > >
          > > Regards,
          > > ~Santosh
          > >
          > >
          > >
          > > ----- Original Message -----
          > > From: paramsan1234
          > > To: perlguitest@yahoogroups.com
          > > Sent: Tuesday, August 22, 2006 11:51 AM
          > > Subject: [perlguitest] PushChildButton Not actually firing the
          > event handler related to the button
          > >
          > >
          > > Hi all!
          > >
          > > My situation:
          > > I am new to perl. I use Win32::GuiTest to achieve some
          > screenscaping
          > > for windows (!!!) popping up "Add New Hardware Wizard".
          > >
          > > Code Snippet:
          > >
          > > use Win32::GuiTest qw(WaitWindowLike PushChildButton SendKeys)
          > >
          > > $Win32::GuiTest::debug = 1; # Set Debugging
          > >
          > > $WinHandle = WaitWindowLike(undef, "^Add New Hardware", "", "",
          > 1200);
          > > # Set a timeout for 1200 seconds
          > >
          > > PushChildButton($WinHandle, "Next >", 0.25);
          > > # Set delay of 250ms for debugging
          > >
          > > # Don't worry about the syntax or compile errors in the code,
          > this
          > > # should serve as a pseudo code to actually what I am doing since
          > > # screen-scraping, which is why I am using Win32::GuiTest is my
          > last
          > > # alternative though I know Win32::GuiTest is extremely useful
          > > # for thousands of windows errands/problems
          > >
          > > Problem:
          > > The code is as complex as it gets above (an irony, acutally it's
          > > simple though!). However the real issue is that sometimes
          > the "Next >"
          > > button gets pushed and sometimes not. So I tried some detailed
          > > checking and figured out that PushChildButton is returning a true
          > > value (1) means that it did it's work though I can't actually see
          > it
          > > press the button and neither does the window proceeds to the next
          > step.
          > > However, I want a bit consistency in my program and want to make
          > sure
          > > that it should work for the 99 % of cases (getting realistic of
          > some
          > > other conditions)
          > >
          > > I haven't seen the bug reports in detail though but I am not sure
          > why
          > > my code will be doing this. It seems as if something is
          > interfering
          > > between the time the PushChildButton's action is sent and the
          > event
          > > handler is kicked off. While, I have seen it work and not work in
          > the
          > > same conditions? Or this might not be a bug at all but some
          > windows thing?
          > >
          > > If any of you went throught the same problem, please help me
          > explain
          > > to as why is this happening and how can I make sure that the Next
          > > button is pressed and the correct event takes place?
          > >
          > > Future Effort:
          > > The next part I am going to try is to put the child button
          > (window) id
          > > instead of the text and;
          > > try using sendMessage(...) somehow?
          > >
          > > Fine Print:
          > > If any of you had any similar threads posted before, please feel
          > free
          > > to redirect me to the correct place and if anything is not clear,
          > I
          > > should try to correct my programming english considering the fact
          > that
          > > I have just dived into the ocean and is still swimming near the
          > shore.
          > >
          > > Thanking all,
          > > Param
          > >
          > >
          > >
          > >
          > >
          > > [Non-text portions of this message have been removed]
          > >
          >
          >
          >
          >
          >
          >
          >
          >
          > Yahoo! Groups Links
          >
          >
          >
          >
          >
          >
          >


          --
          Rgds,
          Girish :-)


          [Non-text portions of this message have been removed]
        • Aravind Lakshminarayanan
          Hi Param, After ensuring that you are trying to access the correct control (Take a log of the handle that you are trying to access and compare it with what you
          Message 4 of 5 , Aug 24, 2006
          • 0 Attachment
            Hi Param,

            After ensuring that you are trying to access the correct control (Take a log of the handle that you are trying to access and compare it with what you see in spy++ application that comes with VStudio), you could alternatively find the window handle to the button (using FindWindowLike(undef,"<Window Name>,"Button",undef,undef) ) and then send a message (using SendMessage(<window handle>,0x00F5,0,0) ) to perform push button.

            Regards
            Aravind

            Girish <girishwill@...> wrote: Hi Param,

            To understand/confirm the exact label/caption of the button use a spy tool
            or try below;
            ----------------------------------------------------------
            my @childwnds = GetChildWindows($MainWin[0]);
            # Where $MainWin[0] is the window containing Next and Finish buttons
            foreach my $CWinHanlde (@childwnds) {
            my $ChildWinName = GetWindowText($CWinHanlde);
            print "$CWinHanlde --> $ChildWinName \n";
            }
            ----------------------------------------------------------
            Hope it helps u

            Thanks
            -Girish.

            On 8/22/06, paramsan1234 <paramsan1234@...> wrote:
            >
            > PushButton does not works totally though, but PushChildButton works
            > now. I don't know what the '&' does to '&Next'?
            > So the text on the next button is like "Next >" while on the finish
            > button is "Finish." As you suggested I used '&Next' and the script
            > worked fine. Now if I use '&Finish' nothing happens but if I
            > use 'Finish' the button gets pushed. What is it doing behind the
            > scenes?
            >
            > [If you are wondering where do I use them, I use them right
            > PushChildButton($windowHandle, '&Next', '0.25');
            > or
            > PushChildButton($windowHandle, 'Finish', '0.25');
            >
            > And Thanks for the suggestion of '&Next' Its working (for now
            > atleast).
            >
            >
            > --- In perlguitest@yahoogroups.com, "Santosh Kumar"
            > <kadlisantosh@...> wrote:
            > >
            > > Param,
            > >
            > > Try using PushButton instead of PushChildButton.
            > > Check this code snippet to click Next button, it works with better
            > consistency (I never faced any issue) with the same "Add Hardware
            > Wizard".
            > >
            > > my $Window = 'Add hardware Wizard';
            > > my @WHdls = FindWindowLike(0, $Window, "" );
            > > my $hwnd = $WHdls[0]; # Window handle
            > > SetForegroundWindow( $hwnd ); # Get Add Hardware Wizard to front
            > and active.
            > > my $result = PushButton( '&Next', '0.5' ); #Click Next with 0.5
            > seconds of delay.
            > > #Now wait for next window, or what ever you want.
            > >
            > > I suppose, issue you are facing could be due to parent window
            > loosing focus / active status while you are sending the
            > PushChildButton action.
            > >
            > > Regards,
            > > ~Santosh
            > >
            > >
            > >
            > > ----- Original Message -----
            > > From: paramsan1234
            > > To: perlguitest@yahoogroups.com
            > > Sent: Tuesday, August 22, 2006 11:51 AM
            > > Subject: [perlguitest] PushChildButton Not actually firing the
            > event handler related to the button
            > >
            > >
            > > Hi all!
            > >
            > > My situation:
            > > I am new to perl. I use Win32::GuiTest to achieve some
            > screenscaping
            > > for windows (!!!) popping up "Add New Hardware Wizard".
            > >
            > > Code Snippet:
            > >
            > > use Win32::GuiTest qw(WaitWindowLike PushChildButton SendKeys)
            > >
            > > $Win32::GuiTest::debug = 1; # Set Debugging
            > >
            > > $WinHandle = WaitWindowLike(undef, "^Add New Hardware", "", "",
            > 1200);
            > > # Set a timeout for 1200 seconds
            > >
            > > PushChildButton($WinHandle, "Next >", 0.25);
            > > # Set delay of 250ms for debugging
            > >
            > > # Don't worry about the syntax or compile errors in the code,
            > this
            > > # should serve as a pseudo code to actually what I am doing since
            > > # screen-scraping, which is why I am using Win32::GuiTest is my
            > last
            > > # alternative though I know Win32::GuiTest is extremely useful
            > > # for thousands of windows errands/problems
            > >
            > > Problem:
            > > The code is as complex as it gets above (an irony, acutally it's
            > > simple though!). However the real issue is that sometimes
            > the "Next >"
            > > button gets pushed and sometimes not. So I tried some detailed
            > > checking and figured out that PushChildButton is returning a true
            > > value (1) means that it did it's work though I can't actually see
            > it
            > > press the button and neither does the window proceeds to the next
            > step.
            > > However, I want a bit consistency in my program and want to make
            > sure
            > > that it should work for the 99 % of cases (getting realistic of
            > some
            > > other conditions)
            > >
            > > I haven't seen the bug reports in detail though but I am not sure
            > why
            > > my code will be doing this. It seems as if something is
            > interfering
            > > between the time the PushChildButton's action is sent and the
            > event
            > > handler is kicked off. While, I have seen it work and not work in
            > the
            > > same conditions? Or this might not be a bug at all but some
            > windows thing?
            > >
            > > If any of you went throught the same problem, please help me
            > explain
            > > to as why is this happening and how can I make sure that the Next
            > > button is pressed and the correct event takes place?
            > >
            > > Future Effort:
            > > The next part I am going to try is to put the child button
            > (window) id
            > > instead of the text and;
            > > try using sendMessage(...) somehow?
            > >
            > > Fine Print:
            > > If any of you had any similar threads posted before, please feel
            > free
            > > to redirect me to the correct place and if anything is not clear,
            > I
            > > should try to correct my programming english considering the fact
            > that
            > > I have just dived into the ocean and is still swimming near the
            > shore.
            > >
            > > Thanking all,
            > > Param
            > >
            > >
            > >
            > >
            > >
            > > [Non-text portions of this message have been removed]
            > >
            >
            >
            >
            >
            >
            >
            >
            >
            > Yahoo! Groups Links
            >
            >
            >
            >
            >
            >
            >

            --
            Rgds,
            Girish :-)

            [Non-text portions of this message have been removed]






            ---------------------------------
            All-new Yahoo! Mail - Fire up a more powerful email and get things done faster.

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