567Re: GetComboContents and GetComboText newbie proble m.
- Sep 9, 2004Hi,
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) -
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
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);
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
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 firstname.lastname@example.org, Chris Hilton <chilton@n...>
> 1. You should probably try running your code with the -w switch toPerl
> (perl -w program.pl) or add the 'use warnings' pragma to yourcode; among
> possibly other things, it should tell you that @combo_boxes isbetter
> written as $combo_boxes.@combo_boxes
> 2. Is there a reason you are using $combo_boxes? You set up
> to be an array of all the windows under IE that has a classmatching
> 'InternetExplorer_TridentCmboBx'. But then you don't check if youactually
> get any windows returned (e.g., die "No CBs found" unless@combo_boxes). You
> then start using the second element returned (); why not thefirst one
> ()? Or any others that might be returned? Are you sure thereeven is a
> second element returned? You should probably consider iteratingacross all
> of the returned windows in @combo_boxes and see if a different onehas what
> you're looking for.don't have
> 3. This is more of just an optimization, but I'm pretty sure you
> to call GetComboText on each element of the combo box. You shouldalready
> have all of the element text in @contents when you callGetComboContents.
> Hope some of that helps.
> Chris Hilton
> -----Original Message-----
> From: robert529742 [mailto:viruskiller@b...]
> Sent: Friday, 03 September, 2004 03:44
> To: email@example.com
> Subject: [perlguitest] GetComboContents and GetComboText newbie
> 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.the
> 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 theseems
> 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 thea
> 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);
> #Determine how big it is..
> foreach (@contents)
> my $size=$i;
> #Iterate through it getting the text and printing it. only it gets
> #single byte lookup, 4 "smiley face" characterswrong
> #like you get if you dump executables to the screen.
> while ($i<$size)
> print "$text\n";
> Any help most gratefully appreciated. What on earth am I doing
> here, and is it completely wrong or just a bit wrong.Service.
> Yahoo! Groups Sponsor
> Yahoo! Groups Links
> To visit your group on the web, go to:
> To unsubscribe from this group, send an email to:
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of
- << Previous post in topic