Sunblood Posted May 5, 2016 Posted May 5, 2016 I'm trying to have an InputBox in my GUI that will automatically complete specific words as you type them, similar to how Chrome will autocomplete the web address you're typing as you type it. The part I can't quite figure out is how to allow the user to continue typing through the autofilled text, changing on the fly if necessary. Here's my starter script: #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiEdit.au3> #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form2", 405, 294, 302, 218) $Input1 = GUICtrlCreateInput("Input1", 140, 110, 121, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $oldinput = "" $match = StringSplit("Firstmatch,secondmatch",",") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch $newinput = GUICtrlRead($input1) If $newinput <> $oldinput and $newinput <> "" Then For $i = 1 to $match[0] If StringLeft($match[$i],StringLen($newinput)) = $newinput Then GUICtrlSetData($input1,$match[$i]) _GUICtrlEdit_SetSel($input1,99,StringLen($newinput)) EndIf Next $oldinput = GUICtrlRead($input1) EndIf WEnd As you type, if the text in the box matches any of the text entries in $match ("firstmatch" or "secondmatch",) it will fill the rest of the text. I've managed to successfully set the text highlight and cursor so that you can continue typing, changing if necessary. The only obstacle right now is that if the text is autofilled to completion, Backspace doesn't work. It immediately autofills the text again. I could probably make a workaround by looking for the actual backspace button press and emulating the feature, but I'd like to see if there is a more native or elegant solution.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now