Jump to content

Recommended Posts

Posted

Is there a way you could have the combo box act like the auto complete function found in explorer? Once you start typing in a word, it will find it in the combo box and display it.

Thanks in advance.

Posted (edited)

Perhap's have it so that when a word is typed in it add's it to an array. Each time you start tpying it get's the first 3 letter's (or how ever many you want) from each word in the array and compare's it to the letter's currently in the combo box. If it's a match then it display's are the possible word's in the combo box that are in the array.

Edited by Burrup

qq

Posted

Requires beta version of autoit

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

Opt('MustDeclareVars',1)

Dim $Label,$Input,$Btn_Search,$Btn_ExactSearch,$Combo,$Btn_Exit
Dim $Status,$msg,$ret, $old_string=""

GuiCreate("ComboBox Find 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)
$Btn_ExactSearch = GuiCtrlCreateButton("Exact Search", 255, 50, 90, 30)
$Combo = GuiCtrlCreateCombo("", 70, 100, 270, 21)
GUICtrlSetData($Combo,"AutoIt|v3|is|freeware|BASIC-like|scripting|language")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
GuiSetState()
While 1
   $msg = GuiGetMsg()
    If $old_string <> GUICtrlRead($Combo) Then
        _AutoComplete($Combo)
        $old_string = GUICtrlRead($Combo)
    EndIf
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
            ExitLoop
        Case $msg = $Btn_Search
            If(StringLen(GUICtrlRead($Input)) > 0) Then
                $ret = _GUICtrlComboFindString($Combo,GUICtrlRead($Input))
                If($ret <> $CB_ERR) Then
                    GUICtrlSetData($Status,'Found "' & GUICtrlRead($Input) & '" at index: ' & $ret)
                Else
                    GUICtrlSetData($Status,'"' & GUICtrlRead($Input) & '" Not Found')
                EndIf
            EndIf
        Case $msg = $Btn_ExactSearch
            If(StringLen(GUICtrlRead($Input)) > 0) Then
                $ret = _GUICtrlComboFindString($Combo,GUICtrlRead($Input),1)
                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

Func _AutoComplete($Combo)
    Local $ret, $s_text, $s_data
    $s_data = GUICtrlRead($Combo)
    $ret = _GUICtrlComboFindString($Combo,GUICtrlRead($Combo))
    If($ret <> $CB_ERR) Then
        _GUICtrlComboGetLBText($Combo,$ret,$s_text)
        GUICtrlSetData($Combo,$s_text)
        _GUICtrlComboSetEditSel($Combo, StringLen($s_data), StringLen(GUICtrlRead($Combo)))
    EndIf
EndFunc

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...