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

567Re: GetComboContents and GetComboText newbie proble m.

Expand Messages
  • robert529742
    Sep 9, 2004
    • 0 Attachment

      Thanks for the replies!

      I hoped to have all the element text from the GetComboContents call.
      When I got a list back ( garbage looking data but the correct number
      of elements ) I decided to try calling GetComboText on each element
      to see if that could resolve the text. It can't, GetcomboText
      returns the exact same thing as GetComboContents

      Run through Komodo I can interact and get a raw dump of what comes
      back from GetComboContents via the debugger ... it's this:


      I get the same returned from GetComboContents($combo_boxes[1]) -
      with warnings on it griped about that being a neater way of doing it
      but didnt start returning me the text.

      I can get the same result on a public page to make things a bit
      clearer, try this code ( uses win32::iemechanize to open a browser
      session and look at http://www.mcafee.com which has one object of
      type InternetExplorer_TridentComboBox) Same stuff comes back. the
      text in the combo is a list of languages, the data that comes back
      from getcombocontents is just a list of references (or somesuch)

      use Win32::GuiTest qw/SendKeys FindWindowLike GetComboContents
      GetComboText GetListText/;
      use Win32::IE::Mechanize;
      use strict;

      my @combo_boxes=();
      my $combo_boxes="";
      my @contents=();
      my $contents="";
      my $text="";
      my $combo="";
      my %contents;
      my $i=0;

      my $ie = Win32::IE::Mechanize->new( visible => 1 );

      #Find the IE window I want
      my ($ie_window) = FindWindowLike(0, "McAfee - Anti-Virus and
      Intrusion Prevention Solutions", "IEFrame");

      #Check I have found it
      die "McAfee is not a window on the screen" unless $ie_window;

      #Find the combo boxes on the page
      @combo_boxes = FindWindowLike($ie_window,"", "Internet

      @contents = GetComboContents(@combo_boxes[0]);

      foreach (@contents)
      print "$_\n";
      print "$text\n";

      This will print out a list of garbage characters, twice each, one
      from the raw $_ output of foreach(@contents) and once from trying to
      resolve some text out of it from GetComboText()

      Please, let me know if you get anything other than garbage out of
      this code!

      Maybe there's something missing from my perl environment, maybe the
      combo box is the wrong sort of box to get text out of, maybe they
      are unicode strings and not GetComboContents(happy) .. I dont know.
      Once again any help gratefully recieved, especially if you run the
      script above and get a nice text list of languages out of it.


      --- In perlguitest@yahoogroups.com, Chris Hilton <chilton@n...>
      > 1. You should probably try running your code with the -w switch to
      > (perl -w program.pl) or add the 'use warnings' pragma to your
      code; among
      > possibly other things, it should tell you that @combo_boxes[1] is
      > written as $combo_boxes[1].
      > 2. Is there a reason you are using $combo_boxes[1]? You set up
      > to be an array of all the windows under IE that has a class
      > 'InternetExplorer_TridentCmboBx'. But then you don't check if you
      > get any windows returned (e.g., die "No CBs found" unless
      @combo_boxes). You
      > then start using the second element returned ([1]); why not the
      first one
      > ([0])? Or any others that might be returned? Are you sure there
      even is a
      > second element returned? You should probably consider iterating
      across all
      > of the returned windows in @combo_boxes and see if a different one
      has what
      > you're looking for.
      > 3. This is more of just an optimization, but I'm pretty sure you
      don't have
      > to call GetComboText on each element of the combo box. You should
      > have all of the element text in @contents when you call
      > Hope some of that helps.
      > Chris Hilton
      > -----Original Message-----
      > From: robert529742 [mailto:viruskiller@b...]
      > Sent: Friday, 03 September, 2004 03:44
      > To: perlguitest@yahoogroups.com
      > Subject: [perlguitest] GetComboContents and GetComboText newbie
      > Hi.
      > Apologies if this is a double post.
      > I am having some problems with the GetComboContents and/or
      > GetComboText functions.
      > Having identified the combo box I want text values out of I call
      > getcombocontents into an array and then call getcombotext on each
      > the entries in that array.
      > However - instead of returning the text of the combo box contents
      > this code returns a single byte, possibly a pointer or lookup to
      > actual text. possibly something completely different. I want the
      > text and it's driving me loopy.
      > I have tried a few variations of iterating through the @contents
      > array, tried doing it in different places in the code, nothing
      > to work. I just get a single raw byte back for each entry in the
      > box. I know this is the right box because there are 26 entries in
      > it, no other box on the page has 26 options.
      > Heres the code I am using.
      > use Win32::GuiTest qw/SendKeys FindWindowLike GetComboContents
      > GetComboText GetListText/;
      > use strict;
      > my @combo_boxes=();
      > my @contents = ();
      > my $text="";
      > my $i=0;
      > #Find the IE window I want
      > my ($ie_window) = FindWindowLike(0, "Bob", "IEFrame");
      > #Check I have found it
      > die "Bob is not a window on the screen" unless $ie_window;
      > #Find the combo boxes on the page ( I think )
      > @combo_boxes = FindWindowLike
      > ($ie_window,"", "InternetExplorer_TridentCmboBx");
      > #theres a few combo boxes, this is the one I want.
      > @contents = GetComboContents(@combo_boxes[1]);
      > #Determine how big it is..
      > foreach (@contents)
      > {
      > $i++;
      > }
      > my $size=$i;
      > $i=0;
      > #Iterate through it getting the text and printing it. only it gets
      > #single byte lookup, 4 "smiley face" characters
      > #like you get if you dump executables to the screen.
      > while ($i<$size)
      > {
      > $text=GetComboText(@combo_boxes[1],$i);
      > print "$text\n";
      > $i++;
      > }
      > Any help most gratefully appreciated. What on earth am I doing
      > here, and is it completely wrong or just a bit wrong.
      > Thanks.
      > -Ed.
      > Yahoo! Groups Sponsor
      > Yahoo! Groups Links
      > To visit your group on the web, go to:
      > http://groups.yahoo.com/group/perlguitest/
      > To unsubscribe from this group, send an email to:
      > perlguitest-unsubscribe@yahoogroups.com
      > Your use of Yahoo! Groups is subject to the Yahoo! Terms of
    • Show all 2 messages in this topic