angel83 Posted January 22 Posted January 22 (edited) HELLO I AM TRYING TO REMOVE THE REPETITIONS BY SEARCHING FOR SUBFOLDERS AND THEN ADDING IN LISTVIEW COLUMN (EXE NAME) AN EXAMPLE OF THE PROBLEM; #|EXE NAME |PATH | 1| WinRAR.exe | C:\Program Files\WinRAR\WinRAR.exe | 2| WinRAR.exe | C:\Program Files\WinRAR-COPY\WinRAR.exe | 3| WinRAR.exe | C:\Program Files\WinRAR-COPY-2\WinRAR.exe | THIS IS MY CODE; expandcollapse popup#include <GuiListView.au3> #include <GUIConstants.au3> #include <WINAPI.au3> #include <misc.au3> #include <ColorConstants.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include <File.au3> #include <GuiComboBox.au3> #include <GuiConstantsEx.au3> #include <GuiEdit.au3> #include <GuiListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Word.au3> Global $g_aFileList[0] Opt("GUIResizeMode", $GUI_DOCKAUTO) $hGUI = GUICreate("Test", 1024, 800) GUISetBkColor(0xFFFF00) $iLVStyle = BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS) $iLVExtStyle = BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT) $hListView = GUICtrlCreateListView("#|EXE NAME|PATH|", 34, 274, 850, 444, $iLVStyle, $iLVExtStyle) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOr($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) _GuiCtrlListView_SetColumnWidth($hListView,0,35) _GuiCtrlListView_SetColumnWidth($hListView,1,290) _GuiCtrlListView_SetColumnWidth($hListView,2,490) $AddButton = GUICtrlCreateButton("Add", 122, 242, 75, 23,$WS_BORDER) $RemButton = GUICtrlCreateButton("Delete", 202, 242, 75, 23,$WS_BORDER) $RemButton3 = GUICtrlCreateButton("Delete All", 298, 242, 88, 23,$WS_BORDER) GUISetState(@SW_SHOW, $hGUI) While 1 $msg = GUIGetMsg(1) Switch $msg[0] Case $GUI_EVENT_CLOSE Exit Case $AddButton REPIT() Case $RemButton _GUICtrlListView_DeleteItemsSelected($hListView) Case $RemButton3 _GUICtrlListView_DeleteAllItems($hListView) EndSwitch WEnd Func REPIT() Local $sBrowseFolder = FileSelectFolder ("Select Folder with Documents to merge", "", 4, @ScriptDir) IF @ERROR THEN Else _AddSelectFolder($sBrowseFolder) EndIf EndFunc Func _AddSelectFolder($_sFolderPath) Local $aFolderList = _FileListToArrayRec($_sFolderPath, "*.exe", $FLTAR_FILES, $FLTAR_RECUR, 1, 2) If @error Then Return _ArrayConcatenate($g_aFileList, $aFolderList, 1) $g_aFileList = _ArrayUnique($g_aFileList, Default, Default, Default, $ARRAYUNIQUE_NOCOUNT) _ArraySort($g_aFileList) Local $aFileList = $g_aFileList _ArrayColInsert($g_aFileList, 0) _ArrayColInsert($g_aFileList, 1) For $i = 0 To UBound($g_aFileList) - 1 $g_aFileList[$i][0] = $i+1 $g_aFileList[$i][1] = StringRegExpReplace($g_aFileList[$i][2], ".*\\", "") $g_aFileList[$i][2] = StringRegExpReplace($g_aFileList[$i][2], "(^.*\).*", "\1") Next _GUICtrlListView_DeleteAllItems($hListView) _GUICtrlListView_AddArray($hListView, $g_aFileList) EndFunc ;==>_AddSelectFolder Edited January 22 by angel83
Developers Jos Posted January 22 Developers Posted January 22 (edited) Whats up with the SHOUTING? On top of that you forgot to tell us what your problem is. Edited January 22 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
angel83 Posted January 22 Author Posted January 22 (edited) Hello Jos, greetings, as I said, the problem is preventing the same names from appearing in the |EXE NAME| column. from list view this is an example; This is how it appears when loading the subfolders and adding them to the ListView. #|EXE NAME |PATH | 1| WinRAR.exe | C:\Program Files\WinRAR\WinRAR.exe | 2| WinRAR.exe | C:\Program Files\WinRAR-COPY\WinRAR.exe | 3| WinRAR.exe | C:\Program Files\WinRAR-COPY-2\WinRAR.exe | So I try to make it appear by replacing the same names and leaving only one. #|EXE NAME |PATH | 1| WinRAR.exe | C:\Program Files\WinRAR\WinRAR.exe | | | | | | | Sorry for not explaining myself better, I hope you understand what I'm trying to do. Edited January 22 by angel83
Solution Dan_555 Posted January 23 Solution Posted January 23 (edited) if IsArray($g_aFileList) then Local $atmp[1][3] EndIf for $i=0 to UBound($g_aFileList)-1 $in=0 for $j=0 to UBound($atmp)-1 if $g_aFileList[$i][1]=$atmp[$j][1] then $in=$in+1 Next if $in=0 then $atmp[UBound($atmp)-1][0] = UBound($atmp) $atmp[UBound($atmp)-1][1] = $g_aFileList[$i][1] $atmp[UBound($atmp)-1][2] = $g_aFileList[$i][2] if $i<UBound($g_aFileList)-3 Then _ArrayAdd($atmp,"") EndIf Next _GUICtrlListView_AddArray($hListView, $atmp) EndFunc ;==>_AddSelectFolder I think this should do it, insert and replace the code after _GUICtrlListView_DeleteAllItems($hListView) in the _AddSelectFolder function. p.s. at least it works the 1st time the add button is clicked ... Edited January 23 by Dan_555 Some of my script sourcecode
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