purushothama Posted July 27, 2018 Share Posted July 27, 2018 Hi, I have created GUI with a list box and a couple of inputboxes and loaded few items into listbox by reading a textfile. Now I want to search the listbox items using one of inputboxes. What i really want is that the matching item in the listbox should get selected as and when i type a character into the input box. Anybody's help is much appreciated. thank you search.au3search.au3 Link to comment Share on other sites More sharing options...
careca Posted July 27, 2018 Share Posted July 27, 2018 Yeah i know what you mean, i did such a thing, maybe you can convert it to your case. expandcollapse popup$SrchRD = GUICtrlRead($Srch) If $SrchRDcmp <> $SrchRD Then $SrchRDempty = 0 $SrchRDcmp = $SrchRD ;============================================================================= _GUICtrlListView_DeleteAllItems($cListView) ;============================================================================= $IniReadSec = IniReadSection($Ini, 'Files') If IsArray($IniReadSec) Then If $IniReadSec[0][0] <> 0 Then For $i = 1 To $IniReadSec[0][0] If StringInStr($IniReadSec[$i][1], $SrchRD) <> 0 Then GUICtrlCreateListViewItem($IniReadSec[$i][0] & '|' & $IniReadSec[$i][1], $cListView) _GUICtrlListView_EnsureVisible($cListView, $i) EndIf Next GUICtrlSendMsg($cListView, $LVM_SETCOLUMNWIDTH, 0, 110) GUICtrlSendMsg($cListView, $LVM_SETCOLUMNWIDTH, 1, -1) $ListCount = _GUICtrlListView_GetItemCount($cListView) If $ListCount <> 0 Then GUICtrlSetData($CountLbl, $ListCount & ' Files') EndIf EndIf EndIf GUIDelete($GMarquee) ;============================================================================= _WinAPI_EmptyWorkingSet(0) ;============================================================================= ElseIf $SrchRD = '' Then If $SrchRDempty = 0 Then $SrchRDempty = 1 ;============================================================================= _GUICtrlListView_DeleteAllItems($cListView) ;============================================================================= $IniReadSec = IniReadSection($Ini, 'Files') If IsArray($IniReadSec) Then If $IniReadSec[0][0] <> 0 Then For $i = 1 To $IniReadSec[0][0] GUICtrlCreateListViewItem($IniReadSec[$i][0] & '|' & $IniReadSec[$i][1], $cListView) _GUICtrlListView_EnsureVisible($cListView, $i) Next GUICtrlSendMsg($cListView, $LVM_SETCOLUMNWIDTH, 0, 110) GUICtrlSendMsg($cListView, $LVM_SETCOLUMNWIDTH, 1, -1) $ListCount = _GUICtrlListView_GetItemCount($cListView) If $ListCount <> 0 Then GUICtrlSetData($CountLbl, $ListCount & ' Files') EndIf EndIf EndIf GUIDelete($GMarquee) EndIf EndIf Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted July 27, 2018 Share Posted July 27, 2018 (edited) @purushothama I think that a WM_COMMAND is quite enough to do what you're trying to do... Do you know anything about that? Take a look right below ( your script modified ): expandcollapse popup#include <ButtonConstants.au3> #include <file.au3> #include <GUIListBox.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <ComboConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("TextExpander", 451, 403, 336, 33) $IP = GUICtrlCreateInput("", 32, 304, 177, 21) ; GUICtrlCreateInput("", 240, 304, 177, 21) $Button1 = GUICtrlCreateButton("OK", 24, 344, 89, 33, $BS_DEFPUSHBUTTON) $Button2 = GUICtrlCreateButton("Add Entry", 136, 344, 105, 33) $Edit1 = GUICtrlCreateList("", 16, 8, 409, 279) $Button3 = GUICtrlCreateButton("Close", 352, 344, 65, 33) GUISetState(@SW_SHOW) LoadData () #EndRegion ### END Koda GUI section ### GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") Func LoadData () Local Const $sFilePath = @ScriptDir & "\Textexpander.txt" Local $hFileOpen = FileOpen($sFilePath, $FO_READ) $sData = fileread($hFileOpen) fileclose($hFileOpen) Global $MyVal = StringSplit($sData,"|") Global $possibles = stringreplace($sdata,@CRLF,'|') GUICtrlSetData($Edit1, $possibles) EndFunc While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $hdlWindowFrom, _ $intControlID_From, _ $intMessageCode, _ $strSearchString = "", _ $intItemIndex = 0 $intControlID_From = BitAND($wParam, 0xFFFF) $intMessageCode = BitShift($wParam, 16) Switch $intControlID_From Case $IP Switch $intMessageCode Case $EN_CHANGE $strSearchString = GUICtrlRead($IP) $intItemIndex = _GUICtrlListBox_FindString($Edit1, $strSearchString) If @error Then ConsoleWrite("Error while searching the string in the ListBox. Error: " & @error & @CRLF) Else _GUICtrlListBox_SetCurSel($Edit1, $intItemIndex) If @error Then ConsoleWrite("Error while selecting the ListBox Item " & $intItemIndex & ".Error: " & @error & @CRLF) EndIf EndIf EndSwitch EndSwitch EndFunc Little suggestion: Use meaningful names for your variables and for your controls Edited July 27, 2018 by FrancescoDiMuro purushothama 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
purushothama Posted July 27, 2018 Author Share Posted July 27, 2018 Thank you very much, that's what I needed. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted July 27, 2018 Share Posted July 27, 2018 @purushothama Happy to have helped Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette 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