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

How do I Get Text from a particular Text box ?

Expand Messages
  • shsk7203
    Hi, I was wondering how I can elegantly code it such that I can use WMGetText on a particular input Text box in the current Active window. Currently, I used
    Message 1 of 3 , Jul 10 10:18 PM
    • 0 Attachment
      Hi,

      I was wondering how I can elegantly code it such that I can use
      WMGetText on a particular input Text box in the current Active
      window. Currently, I used WinSpy to find the classname of the Textbox
      control which happened to be ThunderRT6TextBox.

      Then I use the foll command to load all the Text boxes.

      my @win = FindWindowLike(0, undef, ThunderRT6TextBox);

      Also, through WinSpy I know at what index the Textboxes are loaded in
      my array, so I use hard coded array indexes as in where @win[1] and
      @win[0] contain the values that I want to check:

      if (WMGetText(@win[1]) == @_[0]){
      print "Critical value Saved ";
      print @_[0];
      print "\n";
      }
      else{
      print "Critical value Not Saved ";
      print @_[0];
      print "\n";
      }

      if (WMGetText(@win[0]) == @_[1]){
      print "Warning value Saved " ;
      print @_[1];
      print "\n";
      }
      else{
      print "Warning value Not Saved " ;
      print @_[1];
      print "\n";
      }

      This works, but it's totally inelegant :-( Hope someone can help.

      Regards,
      -skanitkar
    • shsk7203
      Found my solution: Winspy utility at http://www.catch22.org.uk/software/ gives me the control id of the Text box. Foll code returns the warning text: #using
      Message 2 of 3 , Jul 14 3:58 AM
      • 0 Attachment
        Found my solution:

        Winspy utility at http://www.catch22.org.uk/software/ gives me the
        control id of the Text box.

        Foll code returns the warning text:

        #using the Title of my window
        my ($dlg) = FindWindowLike(0, "Threshold");

        #getting the text box
        my ($label1) = WMGetText(FindWindowLike($dlg, "", "", 0x2));

        Regards,
        -skanitkar
        --- In perlguitest@yahoogroups.com, "shsk7203" <shsk7203@y...> wrote:
        > Hi,
        >
        > I was wondering how I can elegantly code it such that I can use
        > WMGetText on a particular input Text box in the current Active
        > window. Currently, I used WinSpy to find the classname of the
        Textbox
        > control which happened to be ThunderRT6TextBox.
        >
        > Then I use the foll command to load all the Text boxes.
        >
        > my @win = FindWindowLike(0, undef, ThunderRT6TextBox);
        >
        > Also, through WinSpy I know at what index the Textboxes are loaded
        in
        > my array, so I use hard coded array indexes as in where @win[1] and
        > @win[0] contain the values that I want to check:
        >
        > if (WMGetText(@win[1]) == @_[0]){
        > print "Critical value Saved ";
        > print @_[0];
        > print "\n";
        > }
        > else{
        > print "Critical value Not Saved ";
        > print @_[0];
        > print "\n";
        > }
        >
        > if (WMGetText(@win[0]) == @_[1]){
        > print "Warning value Saved " ;
        > print @_[1];
        > print "\n";
        > }
        > else{
        > print "Warning value Not Saved " ;
        > print @_[1];
        > print "\n";
        > }
        >
        > This works, but it's totally inelegant :-( Hope someone can help.
        >
        > Regards,
        > -skanitkar
      • Dennis K. Paulsen
        If the VB application is coded elegantly, each of the text boxes would have a meaningfull caption/name assigned to them; which could then be read and used to
        Message 3 of 3 , Jul 14 5:17 AM
        • 0 Attachment
          If the VB application is coded elegantly, each of the text boxes
          would have a meaningfull caption/name assigned to them; which could
          then be read and used to determine which text box is which. Without
          that, I believe there isn't much more elegance that can be obtained
          beyond the solution you've already deployed.

          P.S. I suggest adding `use strict;` and `use warnings;` to your Perl
          scripts at least during development. It can catch some bigger
          problems, but also minor ones like the use of @win[1]/@_[1] vs. the
          more proper $win[1]/$_[1].

          My $0.02,
          Dennis K. Paulsen

          --- In perlguitest@yahoogroups.com, "shsk7203" <shsk7203@y...> wrote:
          > Hi,
          >
          > I was wondering how I can elegantly code it such that I can use
          > WMGetText on a particular input Text box in the current Active
          > window. Currently, I used WinSpy to find the classname of the
          Textbox
          > control which happened to be ThunderRT6TextBox.
          >
          > Then I use the foll command to load all the Text boxes.
          >
          > my @win = FindWindowLike(0, undef, ThunderRT6TextBox);
          >
          > Also, through WinSpy I know at what index the Textboxes are loaded
          in
          > my array, so I use hard coded array indexes as in where @win[1]
          and
          > @win[0] contain the values that I want to check:
          >
          > if (WMGetText(@win[1]) == @_[0]){
          > print "Critical value Saved ";
          > print @_[0];
          > print "\n";
          > }
          > else{
          > print "Critical value Not Saved ";
          > print @_[0];
          > print "\n";
          > }
          >
          > if (WMGetText(@win[0]) == @_[1]){
          > print "Warning value Saved " ;
          > print @_[1];
          > print "\n";
          > }
          > else{
          > print "Warning value Not Saved " ;
          > print @_[1];
          > print "\n";
          > }
          >
          > This works, but it's totally inelegant :-( Hope someone can help.
          >
          > Regards,
          > -skanitkar
        Your message has been successfully submitted and would be delivered to recipients shortly.