Jump to content

Combobox Autocomplete


 Share

Recommended Posts

Hi,

I've searched the forums for this question without luck.

Is it possible to have auto-complete in a Combobox, so that as you type something into a Combobox it auto-completes the word from the list.

Thanks.

good job searching:

http://www.autoitscript.com/forum/index.ph...hl=autocomplete

try again.

---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Link to comment
Share on other sites

Well I guess I only searched for "combobox autocomplete" which doesn't bring up that thread.

also that is not exactly the kind of autocomplete I want, as it gives a dropdown rather than just autocompleting the actual text you're typing.

Thanks anyway though, it might have to do.

Link to comment
Share on other sites

Well I guess I only searched for "combobox autocomplete" which doesn't bring up that thread.

also that is not exactly the kind of autocomplete I want, as it gives a dropdown rather than just autocompleting the actual text you're typing.

Thanks anyway though, it might have to do.

Look in the help of the latest release.

SciTE for AutoItDirections for Submitting Standard UDFs

 

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

 

Link to comment
Share on other sites

  • Moderators

gafrost,

I didn't find anything in the help on this issue.

Also "_GUICtrlComboAutoComplete" I could not find anywhere, can you please elaborate on this?

Do you have the newest "Released Version" or even the last Beta?

Released Version

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

ok, it's under the UDF section.

thanks.

Just an FYI, when you see someone refer you or anyone to the Help file for a function, and you see an underscore "_" in front of the Function name, it's going to be in the User Defined Functions (UDF) section.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Thanks smoke, I gathered that now. I did realise before this was for UDF's, however I wasn't aware there were "official" UDF's actually documented in the helpfile, I assumed they were just contributions of users supported only by the users who created them.

Link to comment
Share on other sites

hmm, ive just used this UDF in a program.

its a list of names, however, i have noticed that if you start to scroll down the list, it automatically moves the item under your cursor into the box.

then auto completes for the input, if you keep moving your cursor down the list, the list starts scrolling (i have 680 odd names in the list)

any ideas on preventing it automatically moving the information under the cursor into the input part of the combo box?

Link to comment
Share on other sites

I've noticed the same glitch, I was thinking you probably need to catch the event of the combo list being opened and makesure it doesn't do auto-complete in this case.

Another question I have which I'm unable to fidn in the help file about combo's is how to set the text to nothing. GUICtrlSetData seems to only be able to set the entire list to nothing, rather than just the control's displayed text.

Link to comment
Share on other sites

you mean, so that the combo box appears blank, until you bring down the list and choose what you want?

there are two spots where this is set:

a:

GUICtrlCreateCombo ( "text", left, top [, width [, height [, style [, exStyle]]]] )

the "TEXT" part should be left as "" and then it will not display that.

b:

GUICtrlSetData ( controlID, data [, default] )

the DEFAULT part of this should be left out.

that way, the combo box should appear blank. all of mine have so far. and those are the only two things i can see that might affect it.

Link to comment
Share on other sites

I've noticed the same glitch, I was thinking you probably need to catch the event of the combo list being opened and makesure it doesn't do auto-complete in this case.

Another question I have which I'm unable to fidn in the help file about combo's is how to set the text to nothing. GUICtrlSetData seems to only be able to set the entire list to nothing, rather than just the control's displayed text.

Not a glitch, especially when no code is provided to show how you used it.

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

Global Const $WM_COMMAND = 0x0111
Global Const $CBN_EDITCHANGE = 5;
Global Const $CBN_SELCHANGE = 1;
Global Const $CBN_EDITUPDATE = 6;
Global Const $DebugIt = 1
Global $old_string = ""

GUICreate("My GUI combo")  ; will create a dialog box that when displayed is centered

$Combo = GUICtrlCreateCombo("", 10, 10)
GUICtrlSetData($Combo, "AutoIt|v3|is|freeware|BASIC-like|scripting|language|Autobot|Animal")
$btn = GUICtrlCreateButton("Ok", 40, 75, 60, 20)

GUISetState()
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()
    Select
        Case $msg = $btn
            ExitLoop
    EndSelect
WEnd

Func _Combo_Changed()
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then    ConsoleWrite (_DebugHeader("Combo Changed:" & GUICtrlRead($Combo)))
    ;----------------------------------------------------------------------------------------------
    _GUICtrlComboAutoComplete($Combo, $old_string)
EndFunc   ;==>_Combo_Changed

Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    Local $nNotifyCode = _HiWord($wParam)
    Local $nID = _LoWord($wParam)
    Local $hCtrl = $lParam
    
    Switch $nID
        Case $Combo
            Switch $nNotifyCode
                Case $CBN_EDITUPDATE, $CBN_EDITCHANGE ; when user types in new data
                    _Combo_Changed()
                Case    $CBN_SELCHANGE ; item from drop down selected
                    _Combo_Changed()
            EndSwitch
    EndSwitch
    ; Proceed the default Autoit3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default Autoit3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_COMMAND

Func _DebugHeader($s_text)
    Return _
            "!===========================================================" & @LF & _
            "+===========================================================" & @LF & _
            "-->" & $s_text & @LF & _
            "+===========================================================" & @LF
EndFunc   ;==>_DebugHeader

Func _HiWord($x)
    Return BitShift($x, 16)
EndFunc   ;==>_HiWord

Func _LoWord($x)
    Return BitAND($x, 0xFFFF)
EndFunc   ;==>_LoWord

SciTE for AutoItDirections for Submitting Standard UDFs

 

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

 

Link to comment
Share on other sites

the combo box in that example does not get affected.

my combo box has 680 options in it...

which requires the combo box to have a scroller on it,

here is my code:

i know its rough, but it does the job i need, i have a habit of making do with what i already know whenever i can.

now, couple it up with a text document... (called "users.txt", and in the same directory as the script) containing upto 100 records.. and you will see the issue that has arisen.

its designed as a way to get a password back for a users account, users dont have access to change there own password, so they are pre-set.

btw, my text doco is in the following format:

codefirstnam last name

ie:

123456tak telapis

it works for my purposes.. but its the way the drop down list behaves thats the issue.

#include <GUIConstants.au3>
#Include <GuiCombo.au3>
#include <file.au3>

GUICreate("ICDL Passwords", 200, 200)
GUISetState (@SW_SHOW)

GUICtrlCreateLabel("Students Name:", 15, 15)
$Username = GUICtrlCreateCombo("", 15, 35, 170, 20)
$old_string = ""
GUICtrlCreateLabel("Type the students name in full", 15, 65)
GUICtrlCreateLAbel("ie: firstname lastname", 15, 80)

$GetPassword = GUICtrlCreateButton("Get Password", 50, 160, 100)

$file = FileOpen(@ScriptDir&"\"&"users.txt", 0)
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file containing passwords")
    Exit
EndIf
$NumberOfLines = _FileCountLines(@ScriptDir&"\"&"users.txt")

$LineNumber = 1
$EndOfFile = ("EndOfFile")
While 1
    $Line = FileReadLine($File, $LineNumber)
    If @error = -1 Then ExitLoop
    $Line1 = Stringlen($Line)
    $Line2 = $line1 - 6
    $Line3 = StringRight($Line, $line2)
    _GUICtrlComboAddString($Username, $line3)
    $LineNumber = $lineNumber + 1
WEnd

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GetPassword
            $UName = StringUpper(GUICtrlRead($Username))
            For $i = 0 To $NumberOfLines Step 1
            $line = FileReadLine($file, $i)
            If @error = -1 Then ExitLoop
            $UsernameAndPassword = StringRegExp($line, $Uname, 0)
                If @extended = 1 then
                    $Password = StringLeft($line, 6)
                    MsgBox(0, "Password Is", "The password for "&GUICtrlRead($Username)&" is: " &$Password)
                EndIF
            Next
        Case $msg = $Username
            MsgBox(0, "test", "case 4 was called")
        Case Else
            _GUICtrlComboAutoComplete ($USername, $old_string)
    EndSelect
WEnd
Edited by tAKTelapis
Link to comment
Share on other sites

the combo box in that example does not get affected.

my combo box has 680 options in it...

which requires the combo box to have a scroller on it,

here is my code:

i know its rough, but it does the job i need, i have a habit of making do with what i already know whenever i can.

now, couple it up with a text document... (called "users.txt", and in the same directory as the script) containing upto 100 records.. and you will see the issue that has arisen.

its designed as a way to get a password back for a users account, users dont have access to change there own password, so they are pre-set.

btw, my text doco is in the following format:

codefirstnam last name

ie:

123456tak telapis

it works for my purposes.. but its the way the drop down list behaves thats the issue.

I gave you a different example above, just adapt that to what you have.

SciTE for AutoItDirections for Submitting Standard UDFs

 

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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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