Jump to content

Autocomplete Input


Recommended Posts

I found a couple of good solutions:

(it shows the list of matching items dynamically, but it works only with the beginning of words and has a combo-size issue)

(it works also with parts of words, but keeps the list always visible)

I'd like to create something of similar, but the idea is a combobox shown in case a particular character is digit and that allows to add the selected text to the input (and not to replace it).

Essentially, the user can digit in the input a path, but can also use environment variables in it. So for example he could digit a first part of the path and than if he digit % a list of env. var. is shown and he can choose to add one of them.

Example:

to obtain "C:\MyFolder\%FileAuthor%"

the user could digit "C:\MyFolder\"

than digit "%" and the list of environment variables is shown

clicking the desired item in the combo, it is added in the input (but without removing the previous string)

Maybe it is not possible to do, I don't know. Can anyone help me with it? Thanks! :)

SFTPEx, AutoCompleteInput_DateTimeStandard(), _ImageWriteResize()_GUIGraduallyHide(): some AutoIt functions.

Lupo PenSuite: all-in-one and completely free selection of portable programs and games.

DropIt: a personal assistant to automatically manage your files.

ArcThemALL!: application to multi-archive your files and folders.

Link to comment
Share on other sites

  • Moderators

Lupo73,

Flattery always helps! :P

Try this:

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#Include <GuiComboBox.au3>

#include <Array.au3>

; Clear flag
$fAdded = False

; Read env vars and put into array
Global Const $sRegKey = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment"
Global $aEnvVar[1][2] = [[0, 0]]
$iCount = 0
While 1
    $iCount += 1
    $sKey = RegEnumVal($sRegKey, $iCount)
    If @error <> 0 Then ExitLoop
    $sValue = RegRead($sRegKey, $sKey)
    $aEnvVar[0][0] = $iCount
    ReDim $aEnvVar[$iCount + 1][2]
    $aEnvVar[$aEnvVar[0][0]][0] = $sKey
    $aEnvVar[$aEnvVar[0][0]][1] = $sValue
WEnd

_ArrayDisplay($aEnvVar)

; Create GUI
$hGUI = GUICreate("Test", 500, 500)

$hInput_1 = GUICtrlCreateInput("",  10, 10, 200, 20)
$hInput_2 = GUICtrlCreateInput("", 260, 10, 200, 20, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY))

$hCombo = GUICtrlCreateCombo("", 10, 40, 200, 20)
GUICtrlSetState($hCombo, $GUI_HIDE)

GUISetState()

; Fill combo
$sComboList = "|"
For $i = 1 To $aEnvVar[0][0]
    $sComboList &= $aEnvVar[$i][0] & "|"
Next
GUICtrlSetData($hCombo, $sComboList)

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    ; Look for input
    $sInput = GUICtrlRead($hInput_1)
    ; If we see the first %
    If StringRight($sInput, 1) = "%" And $fAdded = False Then
        ; Show combo
        GUICtrlSetState($hCombo, $GUI_SHOW)
        _GUICtrlComboBox_ShowDropDown($hCombo, True)
        ; Wait until something is selected in the combo
        While 1
            If GUICtrlRead($hCombo) <> "" And _GUICtrlComboBox_GetDroppedState($hCombo) = False Then
                ; Hide the combo again
                GUICtrlSetState($hCombo, $GUI_HIDE)

                ; Option 1 = add %name%
                GUICtrlSetData($hInput_1, $sInput & GUICtrlRead($hCombo) & "%")

                ; Option 2 = add value
                $iIndex = _ArraySearch($aEnvVar, GUICtrlRead($hCombo))
                GUICtrlSetData($hInput_2, StringTrimRight($sInput, 1) & $aEnvVar[$iIndex][1])

                ; Reset the combo to remove value from edit
                GUICtrlSetData($hCombo, $sComboList)

                ; Set flag to prevent firing on final % of added env variable
                $fAdded = True

                ExitLoop
            EndIf
        WEnd

    ElseIf $sInput = "" Then
        ; Clear second input if first cleared
        GUICtrlSetData($hInput_2, "")
        ; Clear flag for new inputs
        $fAdded = False
    EndIf

WEnd

The second input is only there in case you wanted to add the value of the env variable rather than the name - just delete all reference to it if you do nto need it. :)

Please ask if you have any questions. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thanks for the help! It starts to be similar to the idea :) ..but I have few other questions:

- is it possible to show only the list of the combo after the input and not the combo itself? (like the WideBoyDixon solution and in general like browsers)

- is it possible to support more env. var. in the same string? (for example allow to write "C:\%FileAuthor%\%FileName%")

SFTPEx, AutoCompleteInput_DateTimeStandard(), _ImageWriteResize()_GUIGraduallyHide(): some AutoIt functions.

Lupo PenSuite: all-in-one and completely free selection of portable programs and games.

DropIt: a personal assistant to automatically manage your files.

ArcThemALL!: application to multi-archive your files and folders.

Link to comment
Share on other sites

  • Moderators

Lupo73,

show only the list of the combo after the input and not the combo itself

support more env. var. in the same string?

All you need to do is ask: :)

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#Include <GuiComboBox.au3>

#include <Array.au3>

; Clear flag
$fAdded = False

; Read env vars and put into array
Global Const $sRegKey = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment"
Global $aEnvVar[1][2] = [[0, 0]]
$iCount = 0
While 1
    $iCount += 1
    $sKey = RegEnumVal($sRegKey, $iCount)
    If @error <> 0 Then ExitLoop
    $sValue = RegRead($sRegKey, $sKey)
    $aEnvVar[0][0] = $iCount
    ReDim $aEnvVar[$iCount + 1][2]
    $aEnvVar[$aEnvVar[0][0]][0] = $sKey
    $aEnvVar[$aEnvVar[0][0]][1] = $sValue
WEnd

_ArrayDisplay($aEnvVar)

; Create GUI
$hGUI = GUICreate("Test", 500, 500)

$hCombo = GUICtrlCreateCombo("", 10, 10, 200, 20)

GUISetState()

; Fill combo
$sComboList = "|"
For $i = 1 To $aEnvVar[0][0]
    $sComboList &= $aEnvVar[$i][0] & "|"
Next
GUICtrlSetData($hCombo, $sComboList)

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    ; Look for input
    $sCombo = GUICtrlRead($hCombo)
    ; If we see the first %
    If StringRight($sCombo, 1) = "%" And $fAdded = False Then
        ; Show combo
        _GUICtrlComboBox_ShowDropDown($hCombo, True)
        ; Wait until something is selected in the combo
        While 1
            If GUICtrlRead($hCombo) <> "" And _GUICtrlComboBox_GetDroppedState($hCombo) = False Then
                ; Add %name%
                _GUICtrlComboBox_SetEditText ($hCombo, $sCombo & GUICtrlRead($hCombo) & "%")

                ; Set flag to prevent firing on final % of added env variable
                $fAdded = True

                ExitLoop
            EndIf
        WEnd

    ElseIf StringRight($sCombo, 1) <> "%" And $fAdded = True Then
        ; Clear flag for new inputs
        $fAdded = False
    EndIf

WEnd

Pretty good service for a Sunday afternoon I reckon! :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

It looks good, but a little issued :) sorry.. you are really helpful and I don't want to bore you..

Anyway, these are some issues:

- sometimes when the list is shown, the mouse cursor is hidden

- if no one item is selected from the list and is clicked out of it, in the input is added the previous string + %% (for example "Folder\%" becomes "Folder\%Folder\%%")

- even if the user does not digit %, the combo-arrow allows to show the list of env. var. (essentially it looks like a combo box and not like an input field)

I think a better solution could be obtained starting from WideBoyDixon (combo box seems to produce several problems), but I'm not able to modify it.. I think the result could be useful to other users, given that may be considered an advanced tool to auto-complete input fields :)

SFTPEx, AutoCompleteInput_DateTimeStandard(), _ImageWriteResize()_GUIGraduallyHide(): some AutoIt functions.

Lupo PenSuite: all-in-one and completely free selection of portable programs and games.

DropIt: a personal assistant to automatically manage your files.

ArcThemALL!: application to multi-archive your files and folders.

Link to comment
Share on other sites

  • Moderators

Lupo73,

I think a better solution could be obtained starting from WideBoyDixon

Then I will leave you to it while I watch the Masters on TV! :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

You are right :) ..thanks for your time and for good functions you develop..I'll try to work on it and reply here for good news..

SFTPEx, AutoCompleteInput_DateTimeStandard(), _ImageWriteResize()_GUIGraduallyHide(): some AutoIt functions.

Lupo PenSuite: all-in-one and completely free selection of portable programs and games.

DropIt: a personal assistant to automatically manage your files.

ArcThemALL!: application to multi-archive your files and folders.

Link to comment
Share on other sites

  • Moderators

Lupo73,

Try this version and see if it meets your requirements more closely: :)

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#Include <GuiComboBox.au3>
#include <Misc.au3>

#include <Array.au3>

Opt("GUICloseOnESC", 0)

; Clear flag
$fAdded = False

$iCurrLen = 0
$dll = DllOpen("user32.dll")

; Read env vars and put into array
Global Const $sRegKey = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment"
Global $aEnvVar[1][2] = [[0, 0]]
$iCount = 0
While 1
    $iCount += 1
    $sKey = RegEnumVal($sRegKey, $iCount)
    If @error <> 0 Then ExitLoop
    $sValue = RegRead($sRegKey, $sKey)
    $aEnvVar[0][0] = $iCount
    ReDim $aEnvVar[$iCount + 1][2]
    $aEnvVar[$aEnvVar[0][0]][0] = $sKey
    $aEnvVar[$aEnvVar[0][0]][1] = $sValue
WEnd

;_ArrayDisplay($aEnvVar)

; Create GUI
$hGUI = GUICreate("Test", 500, 500)

$hCombo = GUICtrlCreateCombo("", 10, 10, 200, 20)
GUICtrlSetState(-1, $GUI_HIDE)

$hInput = GUICtrlCreateInput("", 10, 10, 200, 20)

GUISetState()

; Fill combo
$sComboList = "|"
For $i = 1 To $aEnvVar[0][0]
    $sComboList &= $aEnvVar[$i][0] & "|"
Next
GUICtrlSetData($hCombo, $sComboList)

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            On_Exit()
    EndSwitch

    ; Look for input
    $sInput = GUICtrlRead($hInput)

    ; If we see the first %
    If StringRight($sInput, 1) = "%" And StringLen($sInput) > $iCurrLen And $fAdded = False Then

        ; Show combo
        GUICtrlSetState($hCombo, $GUI_SHOW)
        _GUICtrlComboBox_ShowDropDown($hCombo, True)
        While 1
            ; Wait until something is selected in the combo
            If GUICtrlRead($hCombo) <> "" And _GUICtrlComboBox_GetDroppedState($hCombo) = False Then
                _GUICtrlComboBox_ShowDropDown($hCombo, False)
                GUICtrlSetState($hCombo, $GUI_HIDE)
                ; Add %name%
                GUICtrlSetData($hInput, $sInput & GUICtrlRead($hCombo) & "%")
                GUICtrlSetState($hInput, $GUI_FOCUS)
                ControlSend($hGUI, "", $hInput, "{END}")
                ; reset combo
                GUICtrlSetData($hCombo, $sComboList)
                ; Set flag to prevent firing on final % of added env variable
                $fAdded = True
                ; Set length to prevent firing on backspace
                $iCurrLen = StringLen(GUICtrlRead($hInput))
                ExitLoop
            EndIf
            ; Or until Esc pressed which prevents a selection
            If _IsPressed("1B", $dll) Then
                GUICtrlSetData($hInput, StringTrimRight($sInput, 1))
                GUICtrlSetState($hInput, $GUI_FOCUS)
                ControlSend($hGUI, "", $hInput, "{END}")
                _GUICtrlComboBox_ShowDropDown($hCombo, False)
                GUICtrlSetState($hCombo, $GUI_HIDE)
                ExitLoop
            EndIf
            If GUIGetMsg() = $GUI_EVENT_CLOSE Then
                On_Exit()
            EndIf
        WEnd

    ElseIf StringRight($sInput, 1) <> "%" Then
        ; Clear flag for new inputs
        If $fAdded = True Then $fAdded = False
        ; Set new count
        $iCurrLen = StringLen(GUICtrlRead($hInput))
    EndIf

WEnd

Func On_Exit()

    DllClose($dll)
    Exit

EndFunc

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Wow! Great! Thanks for the help.. :)

SFTPEx, AutoCompleteInput_DateTimeStandard(), _ImageWriteResize()_GUIGraduallyHide(): some AutoIt functions.

Lupo PenSuite: all-in-one and completely free selection of portable programs and games.

DropIt: a personal assistant to automatically manage your files.

ArcThemALL!: application to multi-archive your files and folders.

Link to comment
Share on other sites

  • Moderators

Lupo73,

Wow! Great!

I take it from that that the script does what you wanted! Glad I could help. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Nice example Melba23 :unsure:

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

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...