mickdu59 Posted July 2, 2020 Share Posted July 2, 2020 Hello, I have a big problem, the code is looping and I don't know why? and $ desc don't want to display the description, if someone can help me $iniFile = "Config.ini" $array = IniReadSectionNames($iniFile) For $i = 1 To $array[0] $desc = IniRead($iniFile, $array[$i], "Desc", "") _GUICtrlListView_DeleteAllItems($ListView1) ; Is there anything in the input? $sText = GUICtrlRead($Input1) ; search If StringLen($sText) <> 0 Then ; Create a list of matches Local $aMatch_List[1] = [0] $iStart = 1 For $i = 0 To UBound($array) - 1 ; Look for the match If StringInStr($array[$i], $sText) Then ; Add to list $aMatch_List[0] += 1 ReDim $aMatch_List[$aMatch_List[0] + 1] $aMatch_List[$aMatch_List[0]] = $array[$i]&"|"&$desc[$i] ;$ desc[$ i] don't want to work EndIf Next ; Add matches to ListView For $i = 1 To $aMatch_List[0] GUICtrlCreateListViewItem($aMatch_List[$i], $ListView1) Next Else ; Reload everything ContinueCase EndIf Next Link to comment Share on other sites More sharing options...
Subz Posted July 2, 2020 Share Posted July 2, 2020 Don't really understand you delete all items each time you go through the first loop, Place the following below the IniReadSectionNames, not within the first loop. _GUICtrlListView_DeleteAllItems($ListView1) Link to comment Share on other sites More sharing options...
mickdu59 Posted July 2, 2020 Author Share Posted July 2, 2020 this is a piece of code that i get, i want to search in an ini is display the result listview1 $ desc but i can't do it? can someone help me? thank you ini [.NET Core Preview] Switch= Desc=Version d’aperçu du SDK .NET Core. Category=6 [0 A.D.] Switch= Desc=0 A.D. est un jeu gratuit, open-source, historique real time strategy (RTS) actuellement en cours de developpement par Wildfire Games, un groupe mondial de developpeurs de jeux benevoles. En tant que chef d une civilisation ancienne, vous devez rassembler les ressources dont vous avez besoin pour elever une force militaire et dominer vos ennemis. Category=1 Link to comment Share on other sites More sharing options...
Subz Posted July 2, 2020 Share Posted July 2, 2020 Just noticed you have multiple $i, each would have to be different because they're in the same loop, for example use $i, $j etc..., will put an example together for you shortly. Link to comment Share on other sites More sharing options...
Subz Posted July 2, 2020 Share Posted July 2, 2020 Basic example: expandcollapse popup#include <Array.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> Global $g_idListView, $g_idSearch Example() Func Example() GUICreate("listview items", 220, 250) $g_idListView = GUICtrlCreateListView("Section Name|Description", 10, 10, 200, 150) ;,$LVS_SORTDESCENDING) Local $idButton = GUICtrlCreateButton("Search", 75, 170, 70, 20) Local $idItem1 = GUICtrlCreateListViewItem("item2|col22|col23", $g_idListView) Local $idItem2 = GUICtrlCreateListViewItem("item1|col12|col13", $g_idListView) Local $idItem3 = GUICtrlCreateListViewItem("item3|col32|col33", $g_idListView) $g_idSearch = GUICtrlCreateInput("", 20, 200, 150) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton _Search() EndSwitch WEnd EndFunc Func _Search() Local $sSearch = GUICtrlRead($g_idSearch) ;~ No Search text added, so return to Gui If StringStripWS($sSearch, 8) = "" Then Return Local $sConfig = @ScriptDir & "\Config.ini" Local $sDesc, $aSectionNames = IniReadSectionNames($sConfig) If @error Then Return ;~ Delete all items from the list view _GUICtrlListView_DeleteAllItems($g_idListView) For $i = 1 To $aSectionNames[0] If StringInStr($aSectionNames[$i], $sSearch) Then $sDesc = IniRead($sConfig, $aSectionNames[$i], "Desc", "") If StringStripWS($sDesc, 8) = "" Then ContinueLoop GUICtrlCreateListViewItem($aSectionNames[$i] & "|" & $sDesc, $g_idListView) EndIf Next EndFunc mickdu59 and Dan_555 2 Link to comment Share on other sites More sharing options...
Dan_555 Posted July 3, 2020 Share Posted July 3, 2020 Hi, i had a bit of free time, so i could fix your code to work: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 548, 437, 192, 124) $ListView1 = GUICtrlCreateListView("Name | Description", 15, 10, 255, 377) $Input1 = GUICtrlCreateInput("net", 305, 12, 224, 21) $Button1 = GUICtrlCreateButton("Button1", 309, 72, 55, 27) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $iniFile = "Config.ini" While 1 $nMSG = GUIGetMsg() If $nMSG = $Button1 Then _GUICtrlListView_DeleteAllItems($ListView1) $array = IniReadSectionNames($iniFile) ; Is there anything in the input? $sText = GUICtrlRead($Input1) ; search If StringLen($sText) <> 0 Then ; Create a list of matches Local $aMatch_List[1] = [0] $iStart = 1 For $i = 1 To UBound($array) - 1 $desc = IniRead($iniFile, $array[$i], "Desc", "") ; Look for the match If StringInStr($array[$i], $sText) Then ; Add to list $aMatch_List[0] += 1 ReDim $aMatch_List[$aMatch_List[0] + 1] $aMatch_List[$aMatch_List[0]] = $array[$i] & "|" & $desc ;$ desc[$ i] don't want to work because desc is not an array EndIf Next ; Add matches to ListView _GUICtrlListView_BeginUpdate($ListView1) For $i = 1 To $aMatch_List[0] GUICtrlCreateListViewItem($aMatch_List[$i], $ListView1) Next _GUICtrlListView_EndUpdate($ListView1) Else ; Reload everything ;ContinueCase EndIf EndIf If $nMSG = $GUI_EVENT_CLOSE Then Exit WEnd mickdu59 1 Some of my script sourcecode Link to comment Share on other sites More sharing options...
mickdu59 Posted July 4, 2020 Author Share Posted July 4, 2020 Thank you very much you help me greatly Tell me, how to write in an input and send the request without button ok? it's possible ? Link to comment Share on other sites More sharing options...
Subz Posted July 4, 2020 Share Posted July 4, 2020 You could use something like Case $g_idSearch ;~ Pressed Tab If _IsPressed("09") Then _Search() Link to comment Share on other sites More sharing options...
mickdu59 Posted July 4, 2020 Author Share Posted July 4, 2020 On 7/3/2020 at 1:56 AM, Subz said: I find thank you, look Link to comment Share on other sites More sharing options...
Zedna Posted July 4, 2020 Share Posted July 4, 2020 2 hours ago, mickdu59 said: Thank you very much you help me greatly Tell me, how to write in an input and send the request without button ok? it's possible ? #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> $Form1 = GUICreate("Test", 349, 184, 192, 124) $Input1 = GUICtrlCreateInput("", 40, 24, 161, 21) $Label1 = GUICtrlCreateLabel("", 40, 70, 161, 21) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $Msg = GUIGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Func WM_COMMAND($hWinHandle, $iMsg, $wParam, $lParam) If _WinAPI_HiWord($wParam) = $EN_CHANGE And _WinAPI_LoWord($wParam) = $Input1 Then GUICtrlSetData($Label1, GUICtrlRead($Input1)) EndIf EndFunc Subz 1 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
mickdu59 Posted July 4, 2020 Author Share Posted July 4, 2020 (edited) Tell me, this is used to display the title of my software and the description, you think I can add an image? GUICtrlCreateListViewItem($array[$i] & "|" & $desc, $ListView1) Edited July 4, 2020 by mickdu59 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