Sign in to follow this  
Followers 0
Abu Rashid

Combobox Autocomplete

21 posts in this topic

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.

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
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.

Share this post


Link to post
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.

 

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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


[center]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.[/center]

Share this post


Link to post
Share on other sites

I didn't notice a new version released.

I had the latest beta version 3.1.1.133 I think.

Will check latest stable release, thanks for your time.

Share this post


Link to post
Share on other sites

either I'm just not looking hard enough, or it's really well hidden, but I can't seem to find it anyway in the 3.2 help file.

Share this post


Link to post
Share on other sites

ok, it's under the UDF section.

thanks.

Share this post


Link to post
Share on other sites

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.

[center]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.[/center]

Share this post


Link to post
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.

Share this post


Link to post
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?

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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.

 

Share this post


Link to post
Share on other sites

The control is created with a blank text field, but the problem is after an item is selected, there is a "Clear" button which should clear the combo, but not clear the list items. GUICtrlSetData replaces the list items.

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

gafrost,

Apologies for using the term glitch.

I used it exactly as it is, in the example code shown under the UDF section in the help file.

Share this post


Link to post
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.

 

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  
Followers 0