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

143Re: Listbox functions

Expand Messages
  • Ernesto Guisado <erngui@acm.org>
    Dec 15, 2002
      Hi,

      --- In perlguitest@yahoogroups.com, "xGunneRx <xgunnerx@y...>"
      <xgunnerx@y...> wrote:
      > Can anyone show me a good source example of GetListText() when
      using
      > it on a listbox? I've tried to get list text without much sucess. :(

      1) I just opened a application I know contains a listbox (I used
      WinAT).
      2) Run spy--.pl (in win32-guitest\eg) and it shows the listbox
      information:
      <snip>
      +0x000107A0, 'Command Scheduler', WINAT
      ++0x000107A2, '&Remove', Button
      ++0x000107A4, '', ListBox
      ++0x000107A6, '&Add...', Button
      ++0x000107A8, '&Change...', Button
      </snip>
      3) Use Win32::GuiTest to print the content of the first item in the
      list:

      perl -e "use Win32::GuiTest; print Win32::GuiTest::GetListText
      (0x000107A4, 0);"

      4) Alternativelly you can use GetListContents(0x000107A4) to get all
      the items in the list.

      Seems to work.

      My guess is your control looks like a built-in listbox, but really
      isn't. Perhaps some Java thingy or some cross-platform GUI. Spy--.pl
      should tell you what it isn't (check if the class name is "ListBox").

      To help you here's a version of spy.pl that shows contents of
      listboxes as "<item1|item2!...>":

      use Win32::GuiTest qw/FindWindowLike GetWindowText GetClassName
      GetChildDepth GetDesktopWindow GetListContents/;

      for (FindWindowLike()) {
      $s = sprintf("0x%08X", $_ );
      $s .= ", '" . GetWindowText($_) . "', " . GetClassName($_);
      $depth = GetChildDepth(GetDesktopWindow(), $_);
      print "+" x $depth, $s, "\n";
      if (GetClassName($_) eq "ListBox") {
      print "+" x ($depth+1), "<", join("|", GetListContents
      ($_)), ">\n";
      }
      }


      HTH,
      Ernesto.
      -- Ernesto Guisado <mailto:erngui@...>, <http://triumvir.org>
    • Show all 6 messages in this topic