Jump to content
Sign in to follow this  

Dropdown box and List box selections bu string

Recommended Posts


Hi All;

Still learning, but after messing around for a few hours thought it would be best to ask the collective wisdom.

I am writing a script to automate some functions on a window. I've got most of it working, but now have two problems. First, I have a drop-down list control that expands when the down arrow icon is clicked to show about 2 dozen items. I want to select one of them based on the string (such as "Color"). I can force this using MouseClick, of course, but I want it to be string-based instead of location-based. I don't know how to locate a string in the drop-down box (the box contents are not stored in a file, but generated as metadata by the application). I need search only for the first letter of the string, then click that option.

The second problem is similar. After selecting an item from the drop-down list, a listbox is populated with valid entries (such as "red", "blue", etc). I want to select one of these based again on first letter as it appears in the listbox.

So, I'm sure there's some really simple way to do this that I'm missing. Any ideas?



Share this post

Link to post
Share on other sites

Hello TCPI,

I'm not sure if this helps but here is a little example.

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListBoxConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form3 = GUICreate("Form3", 413, 298, 303, 219)
$Combo1 = GUICtrlCreateCombo("", 104, 80, 121, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "one|two|four|six|eight|nine")
$List1 = GUICtrlCreateList("", 104, 184, 121, 97)
GUICtrlSetData(-1, "black|green|orange|pink|red|violet|yellow")
$Input1 = GUICtrlCreateInput("", 104, 32, 121, 21)
$Input2 = GUICtrlCreateInput("", 104, 136, 121, 21)
$Label1 = GUICtrlCreateLabel("letter for combo", 24, 32, 77, 17)
$Label2 = GUICtrlCreateLabel("letter for list", 40, 138, 57, 17)
$Button1 = GUICtrlCreateButton("Apply", 248, 28, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Apply", 249, 134, 75, 25, 0)
$Label3 = GUICtrlCreateLabel("(o,t,f,s or n)", 120, 56, 57, 17)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
        case $button1
        case $Button2


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post

Link to post
Share on other sites

Thanks...I aprpeciate the fast and helpful reply.

I had managed to get the triggering based on first letter of the entry using keyboard commands, but in some cases I have multiple options in the pull-down and selection boxes that start with the same letter (such as "b"). I was trying to match by the entire string (such as "blue" or "black") but can't seem to do that without manipulating the code behind the dialog. If it try to feed the letters (b-l-u-e) it goes to "b" first, then to "l" as a first letter, then to "u" as a first letter, etc. I can't find a way to search the control for the entire string in the control (which is created by ASPX). I can manipulate the ASPX, of course, but not the dialog in this way.

Any thoughts? Or is this just not easily done?


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