Maniacwithit Posted January 20, 2016 Share Posted January 20, 2016 Hello, I have a list for example: 1. boring noses 2. bricking wall 3. balley vall 4. crowded lifts etc... and I want to search in it by typing something like 'b* n' and i would like it to automatically change to 'boring noses'. Can somebody help me with this problem, pls? Link to comment Share on other sites More sharing options...
jguinch Posted January 20, 2016 Share Posted January 20, 2016 Is it for a GUI ? Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Maniacwithit Posted January 20, 2016 Author Share Posted January 20, 2016 Yes, I want to use it to fill a window in a program Link to comment Share on other sites More sharing options...
jguinch Posted January 20, 2016 Share Posted January 20, 2016 Can you show the code you made ? Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Maniacwithit Posted January 21, 2016 Author Share Posted January 21, 2016 (edited) expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <Array.au3> #include <File.au3> #Include <GuiListBox.au3> Global $hGUI, $hInput, $hList, $sPartialData, $asCities, $sAllCities, $iCurrIndex $hGUI = GUICreate("Miasta", 200, 400,-1,-1,bitor($WS_BORDER,$WS_POPUP)) $hInput = GUICtrlCreateInput("", 5, 5, 190, 20) $hList = GUICtrlCreateList("", 5, 30, 190, 325, BitOR(0x00100000, 0x00200000)) $hButton = GUICtrlCreateButton("Read", 60, 360, 80, 30) $hUP = GUICtrlCreateDummy() $hDOWN = GUICtrlCreateDummy() $hENTER = GUICtrlCreateDummy() GUISetState(@SW_SHOW, $hGUI) ; Create list full of random 12 character "words" FillList() ; Set accelerators for Cursor up/down and Enter Dim $AccelKeys[3][2]=[["{UP}", $hUP], ["{DOWN}", $hDOWN], ["{ENTER}", $hENTER]] GUISetAccelerators($AccelKeys) $sCurr_Input = "" $iCurrIndex = -1 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hList $sChosen = GUICtrlRead($hList) If $sChosen <> "" Then GUICtrlSetData($hInput, $sChosen) Case $hButton If $sPartialData <> "" Then $sFinal = GUICtrlRead($hInput) msgbox(0,"",UBound($asCities)) If _ArraySearch($asCities, $sFinal) > 0 Then MsgBox(0, "Chosen", $sFinal) EndIf EndIf Case $hUP $iCurrIndex -= 1 If $iCurrIndex < 0 Then $iCurrIndex = 0 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) Case $hDOWN $iTotal = _GUICtrlListBox_GetCount($hList) $iCurrIndex += 1 If $iCurrIndex > $iTotal - 1 Then $iCurrIndex = $iTotal - 1 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) Case $hENTER if $iCurrIndex = -1 Then $iCurrIndex = 0 ;$sText = _GUICtrlListBox_GetText($hList, $iCurrIndex) ;GUICtrlSetData($hInput, $sText) ;$iCurrIndex = -1 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndSwitch ; If input has changed, refill list with matching items If GUICtrlRead($hInput) <> $sCurr_Input Then UpdateList() $sCurr_Input = GUICtrlRead($hInput) EndIf WEnd ;filters list with matching values Func UpdateList() $sPartialData = "|" ; Start with delimiter so new data always replaces old Local $sInput = GUICtrlRead($hInput) ;$sInput = StringReplace($sInput,"*",".*"); this thing works in Autohotkey version ;$sInput = StringUpper($sInput) If $sInput <> "" Then For $i = 0 To UBound($asCities) -1 If Stringinstr($asCities[$i], $sInput) = 1 Then $sPartialData &= $asCities[$i] & "|" ; below is my code, bot it works not well ;If StringRegExp($asCities[$i], $sInput) <> 0 Then $sPartialData &= $asCities[$i] & "|" Next Else $sPartialData = $sAllCities $iCurrIndex = -1 EndIf GUICtrlSetData($hList, $sPartialData) EndFunc ;==>UpdateList ;reads Cities from file and loads to ListBox Func FillList() $sAllCities = "|" $file = "miasta.txt" _FileReadToArray($file, $asCities) _ArraySort($asCities) For $i = 1 to UBound($asCities) -1 $sAllCities &= $asCities[$i] & "|" Next GUICtrlSetData($hList, $sAllCities) $iCurrIndex = -1 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndFunc ;==>FillList Edited January 21, 2016 by Melba23 Added code tags Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 21, 2016 Moderators Share Posted January 21, 2016 Hi all, After a PM exchange with the OP this is definitely not a game, so there was no need to report it. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted January 21, 2016 Share Posted January 21, 2016 I wonder if this would work for you and maybe add in some tweaking so that * is converted into .* for regex. It may not plug right into your code, but the concept should work. Link to comment Share on other sites More sharing options...
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