Jump to content
Sign in to follow this  
jruelan

What does SelectString really do in ControlCommand?

Recommended Posts

jruelan

can SelectString select the string "testOnly" in a combo box.. here's the script

ControlCommand($winTitle,$winText,$guiControl,"SelectString","test")

I only used "test", can SelectString find the string i want in the combo box? tnx anyone

"SelectString", 'string' Sets selection according to string in a ListBox or ComboBox

I am quite confused in the API

Edited by jruelan

Share this post


Link to post
Share on other sites
zerobazar

Hi,

You may want to use GuiCombo.au3 UDF which will give you much more functions to play with Combo Box (rather than struggling with controlcommand).

Here is the example taken directly from the help file for _GUICtrlComboSelectString function. It should help you.

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Label,$Input,$Btn_Search,$Combo,$Btn_Exit,$Status,$msg,$ret

GuiCreate("ComboBox Select String", 392, 254)

$Label = GuiCtrlCreateLabel("Enter Search String", 20, 20, 120, 20)
$Input = GuiCtrlCreateInput("", 160, 20, 180, 20)
$Btn_Search = GuiCtrlCreateButton("Search", 160, 50, 90, 30)
$Combo = GuiCtrlCreateCombo("", 70, 100, 270, 100,$CBS_SIMPLE)
GUICtrlSetData($Combo,"AutoIt|v3|is|freeware|BASIC-like|scripting|language")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 200, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
            ExitLoop
        Case $msg = $Btn_Search
            If(StringLen(GUICtrlRead($Input)) > 0) Then
                $ret = _GUICtrlComboSelectString($Combo,-1,GUICtrlRead($Input))
                If($ret <> $CB_ERR) Then
                    GUICtrlSetData($Status,'Found "' & GUICtrlRead($Input) & '" at index: ' & $ret)
                Else
                    GUICtrlSetData($Status,'"' & GUICtrlRead($Input) & '" Not Found')
                EndIf
            EndIf
    EndSelect
WEnd
Exit

Search AutoIt help file with GuiCombo Management in the User defined Functions chapter.

Regards.

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  

×