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

How to know button is enabled or disabled?

Expand Messages
  • ashastry06
    Hi, I want to click the button only, if the button is enabled. if not do something else. Please tell what am I doing wrong? Attaching part of my code. my
    Message 1 of 3 , Jan 4, 2006
    • 0 Attachment
      Hi,
      I want to click the button only, if the button is enabled. if not
      do something else. Please tell what am I doing wrong? Attaching part
      of my code.


      my @childern = GetChildWindows($_);
      for (@childern) {
      $buttonName = WMGetText($_);
      print $buttonName,"\n";
      $className = GetClassName($_);
      # $BName == ("^\&Options" );

      if ($buttonName == $BName ) {
      $res = IsWindowEnabled($BName) ;
      if($res == 'TRUE'){
      MouseMoveAbsPix($x+150,$y+305);#Options
      SendMouse("{LEFTCLICK}");
      print "in while loop","\n";
      }
      print "out of while loop","\n";
      }
      else {
      print "whoops","\n";
      }

      }


      Thanks,
      Aparna
    • Dennis K. Paulsen
      Hello, 1) Make sure your using use strict; and use warnings; to catch many common coding errors. 2) I assume $BName is defined somewhere, and that it
      Message 2 of 3 , Jan 8, 2006
      • 0 Attachment
        Hello,

        1) Make sure your using "use strict;" and "use warnings;" to catch
        many common coding errors.
        2) I assume $BName is defined somewhere, and that it doesn't contain
        the regular expression syntax ^ \ since your not using the regexp
        comparison =~ when you compare $buttonName against $BName.
        3) IsWindowEnabled takes a window handle, therefore you could use $_
        as its parameter given your code. Currently your sending it a button
        name.
        4) IsWindowEnabled returns a boolean value, therefore comparing it
        against the text string 'TRUE' is not valid. You could use "if ($res)
        {" instead.
        5) Try not to hardcode coordinates (150, 305)... You might consider
        using PushButton or MouseClick functions to help.


        Regards,
        DKP

        --- In perlguitest@yahoogroups.com, "ashastry06" <aparnashastry@h...>
        wrote:
        >
        > Hi,
        > I want to click the button only, if the button is enabled. if not
        > do something else. Please tell what am I doing wrong? Attaching part
        > of my code.
        >
        >
        > my @childern = GetChildWindows($_);
        > for (@childern) {
        > $buttonName = WMGetText($_);
        > print $buttonName,"\n";
        > $className = GetClassName($_);
        > # $BName == ("^\&Options" );
        >
        > if ($buttonName == $BName ) {
        > $res = IsWindowEnabled($BName) ;
        > if($res == 'TRUE'){
        > MouseMoveAbsPix($x+150,$y+305);#Options
        > SendMouse("{LEFTCLICK}");
        > print "in while loop","\n";
        > }
        > print "out of while loop","\n";
        > }
        > else {
        > print "whoops","\n";
        > }
        >
        > }
        >
        >
        > Thanks,
        > Aparna
        >
      • santoshkadli
        Hi, I assume $BName is defined or have a specific value being assigned before comparing. So check by editing following, 1) if ($buttonName eq $BName) 2) $res =
        Message 3 of 3 , Jan 14, 2006
        • 0 Attachment
          Hi,
          I assume $BName is defined or have a specific value being assigned
          before comparing. So check by editing following,
          1) if ($buttonName eq $BName)
          2) $res = IsWindowEnabled($buttonName); --> Once TRUE
          3) Instead of,
          MouseMoveAbsPix($x+150,$y+305);#Options
          >SendMouse("{LEFTCLICK}");

          try, PushChildButton( $ParentWindowHandle, "$ButtonName", 0.25 );

          ~Santosh



          --- In perlguitest@yahoogroups.com, "ashastry06" <aparnashastry@h...>
          wrote:
          >
          > Hi,
          > I want to click the button only, if the button is enabled. if not
          > do something else. Please tell what am I doing wrong? Attaching part
          > of my code.
          >
          >
          > my @childern = GetChildWindows($_);
          > for (@childern) {
          > $buttonName = WMGetText($_);
          > print $buttonName,"\n";
          > $className = GetClassName($_);
          > # $BName == ("^\&Options" );
          >
          > if ($buttonName == $BName ) {
          > $res = IsWindowEnabled($BName) ;
          > if($res == 'TRUE'){
          > MouseMoveAbsPix($x+150,$y+305);#Options
          > SendMouse("{LEFTCLICK}");
          > print "in while loop","\n";
          > }
          > print "out of while loop","\n";
          > }
          > else {
          > print "whoops","\n";
          > }
          >
          > }
          >
          >
          > Thanks,
          > Aparna
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.