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

How can I read the "widget" label?

Expand Messages
  • shiftibm
    I have a window with the title Response and with 2 TEdit and 1 TComboBox . Each widget (seems to) has a label (it s probably a kind of property?). I
    Message 1 of 1 , Feb 13, 2004
      I have a window with the title "Response" and with 2 "TEdit" and
      1 "TComboBox". Each widget (seems to) has a label (it's probably a
      kind of property?). I would like to read those label... For example,
      the "TComboBox" have a label "Action" associated to it. I use the
      following code and try to read the "TComboBox" label "Action".

      I use the "spy--" script provide in example:


      # $Id: spy--.pl,v 1.1 2001/06/17 09:17:10 erngui Exp $
      # MS has a very nice tool (Spy++).
      # This is Spy--
      use Win32::GuiTest qw/FindWindowLike GetWindowText GetClassName
      GetChildDepth GetDesktopWindow GetComboContents
      GetListContents GetListText WMGetText/;

      # Find the "Response" window
      for (FindWindowLike(0, "^Response"))
      # For each widget in this window
      for(FindWindowLike($_, "", "", ""))
      $s = sprintf("0x%08X", $_ );
      $s .= ", '" . GetWindowText($_) . "', " . GetClassName($_);
      print "+" x GetChildDepth(GetDesktopWindow(), $_), $s, "\n";

      # If the widget is a combo box
      if($s =~ /ComboBox/)
      print "My combo contents is : ", GetComboContents($_), "\n";
      print "My combo text is: ", WMGetText($_), "\n";

      # Get the child (if any)
      my @aChild = FindWindowLike($_, "", "", "");

      # Number of child
      print "Nb child: ", scalar(@aChild), "\n";
      ### END OF SCRIPT

      Here is my output:

      +++++0x00C402C0, '', TComboBox
      My combo contents is : ACDENS
      My combo text is: S
      Nb child: 0

      As you can see above, the "TComboBox" is populated
      with 'A', 'C', 'D', 'E', 'N' and 'S'. The current selection is 'S'.
      There is no "win text" associated with. There is no "sub-widget"
      build within the "TComboBox" (child = 0).

      Note: I have the same problem with the "TEdit" widget...

      Thanks for your help!
    Your message has been successfully submitted and would be delivered to recipients shortly.