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

565RE: [perlguitest] GetComboContents and GetComboText newbie proble m.

Expand Messages
  • Chris Hilton
    Sep 8, 2004
      1. You should probably try running your code with the -w switch to Perl
      (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 better
      written as $combo_boxes[1].

      2. Is there a reason you are using $combo_boxes[1]? You set up @combo_boxes
      to be an array of all the windows under IE that has a class matching
      'InternetExplorer_TridentCmboBx'. But then you don't check if you actually
      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 already
      have all of the element text in @contents when you call GetComboContents.

      Hope some of that helps.

      Chris Hilton

      -----Original Message-----
      From: robert529742 [mailto:viruskiller@...]
      Sent: Friday, 03 September, 2004 03:44
      To: perlguitest@yahoogroups.com
      Subject: [perlguitest] GetComboContents and GetComboText newbie problem.


      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 of
      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 the
      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 seems
      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 a
      #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 wrong
      here, and is it completely wrong or just a bit wrong.

      Thanks.

      -Ed.




      Yahoo! Groups Sponsor
      ADVERTISEMENT






      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 Service.
    • Show all 2 messages in this topic