Jump to content
Sign in to follow this  

How to scrape the text of a drop-down list in an application?

Recommended Posts


I'm trying to use AutoIt to scrape the contents of a particular drop-down list in a particular dialog box. Can someone help me get the right code to do this?

In this case, the application is Verizon VZAccess Manager, which is a connection manager program that controls the connection to Verizon for USB WWAN dongles. Sometimes, if you remove a WWAN card, if you plug in a different model of WWAN card, or if you plug in more than one WWAN card at the same time, then VZAM will put up a dialog box asking you which device you want to control. The list of possible devices is shown in a drop-down list in the dialog box.

My AutoIt script needs to intelligently answer this dialog box and make the correct selection, based on some other information that I've already retrieved elsewhere.

Ideally, I want to be able to scrape the contents of each item in that drop down list, and then be able to analyze and do string comparison operations on every single item in the drop down list (i.e., not just the selected item, but all of them, sequentially in turn), and then, based on the results of those string comparisons, have my AutoIt script make an intelligent choice as to which item should be selected, then select that item and press Enter.

My problem is that every time I try to do ControlGetText on this box, the text that comes back is only the selected item, not the entire contents of the list. I'm trying to figure out the right set of functions to scrape this control in a useful way. I can WinGetText on the box, but it also only shows the currently selected list entry (i.e., it also can't see the other items in the drop down list), and, it mixes up that text with all the other text in the Window anyway, thus making WinGetText kind of useless for what I want to do.

Attached to this post are a pair of screen shots of the dialog box showing that the "Text" is blank when looking at the control details, but, the text is visible in the "Visible Text" tab. Hopefully you can see my dilemma by looking at these screen shots.

Here is my current code:

$con_mgr="VZAccess Manager"
   $handle=WinGetHandle($con_mgr, "")
   If ($handle <> "") then
          $SubWindow = "Configured Device Removed"
          $handle=WinGetHandle($SubWindow, "")
          If ($handle <> "") then
                 $VZAMListBoxString = ControlGetText($handle, "", "[CLASS:ComboBox; INSTANCE:1]")
                 UpdateLogFile ("Retrieve VZAM List Box String: " & $VZAMListBoxString)

The code above, only shows the currently selected text in that drop down list. How do I retrieve each of the items in that list, preferably into an array I can iterate through?



Edited by tfabris

Share this post

Link to post
Share on other sites

Okay, you know what? Maybe I don't need to get that detailed. Maybe what I'll try is this:

- Focus the control.

- ControlGetText to scrape the currently-selected item in the control.

- Perform my string comparisons on the contents of that item.

- If the string comparisons are "good" then press ENTER on the box (i.e, the right selection has been made and we can just confirm the box and be done).

- If the string comparisons are "bad", press DOWN ARROW to get the next item to appear in the list, and then try another scrape and another comparison.

- If the string comparisons never work after a few selections, press ENTER anyway just to get past the box with whatever is selected.

That should get the same results, without me having to know how to scrape that box in detail.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.