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

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

Expand Messages
  • Chris Hilton
    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
    Message 1 of 2 , Sep 8 9:02 AM
    • 0 Attachment
      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.
    • robert529742
      Hi, 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
      Message 2 of 2 , Sep 9 1:55 AM
      • 0 Attachment
        Hi,

        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:

        GetComboContents(@combo_boxes[1])
        [
        "d\\\xB4\1",
        "\xA4\\\xB4\1",
        "\xE4\\\xB4\1",
        "\24]\xB4\1",
        "T]\xB4\1",
        "\xB4]\xB4\1",
        "\4^\xB4\1",
        "D^\xB4\1",
        "\xD4T\xB4\1",
        "\x84V\xB4\1",
        "\xA4V\xB4\1",
        "\4W\xB4\1",
        "DW\xB4\1",
        "Db\xB4\1",
        "\x84b\xB4\1",
        "\xC4b\xB4\1",
        "\xF4b\xB4\1",
        "tc\xB4\1",
        "\xA4c\xB4\1",
        "\xE4c\xB4\1",
        "\24d\xB4\1",
        "Td\xB4\1",
        "\x84d\xB4\1",
        "\xA4d\xB4\1",
        "\xD4d\xB4\1",
        "\x84e\xB4\1",
        ]

        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 );
        $ie->get("http://www.mcafee.com/us/default.asp");

        #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
        Explorer_TridentCmboBx");

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

        $combo=$combo_boxes[0];
        foreach (@contents)
        {
        print "$_\n";
        $text=GetComboText($combo,$i);
        print "$text\n";
        $i++;
        }

        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.

        -Ed.




        --- In perlguitest@yahoogroups.com, Chris Hilton <chilton@n...>
        wrote:
        > 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@b...]
        > 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.
      Your message has been successfully submitted and would be delivered to recipients shortly.