Jump to content

Inputbox Auto Complete


notta
 Share

Recommended Posts

How would you get started in trying to create an inputbox that when the user types a few characters it autofills based upon the letters the user types? I have an inputbox that we type the name of an application, but now the list has grown too long to be a drop down menu. I was hoping to create an autofill that when we type a few characters it fills the field based upon the first few characters typed.

I would think that I load an array with all the application names and then do a search per keystroke. From there I'm lost :D Any ideas? Thanks.

Link to comment
Share on other sites

I think that, to do what you want, you would have to subclass the input control. However, I don't know if that can be done with AutoIt. How about it, GUI gurus? Can an AutoIt input control be subclassed?

Link to comment
Share on other sites

How would you get started in trying to create an inputbox that when the user types a few characters it autofills based upon the letters the user types? I have an inputbox that we type the name of an application, but now the list has grown too long to be a drop down menu. I was hoping to create an autofill that when we type a few characters it fills the field based upon the first few characters typed.

I would think that I load an array with all the application names and then do a search per keystroke. From there I'm lost :D Any ideas? Thanks.

I would expect that all you need to do is use $EN_CHANGE

Here's one way

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>

$possibles = StringSplit("oranges|orchids|ordinal|ordinarily|ordinariness", '|')
;AdlibEnable("highlightIP", 400)

Dim $IPList[3];the inputs
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

$gui = GUICreate("My GUI edit"); will create a dialog box that when displayed is centered

$IP = GUICtrlCreateInput("", 10, 40, 200, 22)
$lab = GUICtrlCreateLabel("", 10, 18, 80, 22)

GUISetState()


While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop


WEnd



Func WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    $nNotifyCode = BitShift($wParam, 16)
    $nID = BitAND($wParam, 0x0000FFFF)
    If $nID = $IP Then
        $hCtrl = $lParam
        If $nNotifyCode = $EN_CHANGE Then
            $txt = GUICtrlRead($IP)
            For $n = 1 To UBound($possibles) - 1
                If StringCompare(StringLeft($possibles[$n], StringLen($txt)), $txt) = 0 Then
                    GUICtrlSetData($lab, $possibles[$n])
                    ExitLoop
                EndIf
            Next
            
        EndIf
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc  ;==>WM_COMMAND
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.
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...