angel83 Posted February 3, 2025 Posted February 3, 2025 (edited) helo. the help with my problem is that it doesn't alphabetically name the names in the listview when adding subforders. 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|EXE 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,290) $AddButton = GUICtrlCreateButton("Add Subfolders", 90, 242, 85, 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 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $AddButton AddSubfolders1() Case $RemButton _GUICtrlListView_DeleteItemsSelected($hListView) Case $RemButton3 _GUICtrlListView_DeleteAllItems($hListView) EndSwitch WEnd Func AddSubfolders1() Local $sBrowseFolder = FileSelectFolder ("Select Folder with Documents to merge", "", 4, @ScriptDir) IF Not @error Then _AddSelectFolder($sBrowseFolder) EndIf EndFunc Func _AddSelectFolder($_sFolderPath) Local $aFolderList = _FileListToArrayRec($_sFolderPath, "*.exe", $FLTAR_FILES, $FLTAR_RECUR, 1, 2) _ArrayConcatenate($g_aFileList, $aFolderList, 1) $g_aFileList = _ArrayUnique($g_aFileList, Default, Default, Default, $ARRAYUNIQUE_NOCOUNT) _ArraySort($g_aFileList,1) _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], "\\\[^\\\]*$", "") Next _GUICtrlListView_DeleteAllItems($hListView) ;remove duplicates 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 you also have another problem if there are duplicates with the same name exe in subfolders it will only select one. i can't get the main executables from a parant folder thank. Edited February 6, 2025 by angel83
angel83 Posted February 5, 2025 Author Posted February 5, 2025 (edited) Any example you give me please is good, to continue with my code. Edited February 5, 2025 by angel83
Developers Jos Posted February 5, 2025 Developers Posted February 5, 2025 I guess nobody is listening and keeping their ears closed since you are SHOUTING AGAIN. 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 February 5, 2025 Author Posted February 5, 2025 (edited) Sorry JOS for getting desperate, I apologize. Edited February 5, 2025 by angel83
Nine Posted February 5, 2025 Posted February 5, 2025 37 minutes ago, angel83 said: I apologize Don't. Just edit your first post with standard (non-bold, non-color, non-upper, non-agressive) font and somebody might listen to you... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
angel83 Posted February 5, 2025 Author Posted February 5, 2025 thanks for the advice. I didn't know, I'm sorry. I'm going to edit the topic
Nine Posted February 5, 2025 Posted February 5, 2025 5 minutes ago, angel83 said: ready Not yet. You forgot non-upper. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
angel83 Posted February 5, 2025 Author Posted February 5, 2025 (edited) YOU REFER TO THIS [ListView] IF IT IS YES I EDIT IT Edited February 5, 2025 by angel83
Nine Posted February 6, 2025 Posted February 6, 2025 Sadly, you do not seem to understand (I suppose it is a language barrier). Nevertheless, we HATE being replied in uppercase. This is my last attempt on you to change your posts to lowercase and have a respectful attitude toward the community. Wish you get it this time... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
angel83 Posted February 6, 2025 Author Posted February 6, 2025 I understand that I didn't do it for that purpose. I just didn't know it was an offense. sorry for not knowing. maybe there are many things that I don't know if you can tell me where I can find more information so I don't make the same mistake. I would appreciate it. changing the theme to lowercase letters as you suggest.
Developers Jos Posted February 6, 2025 Developers Posted February 6, 2025 3 hours ago, angel83 said: I understand that I didn't do it for that purpose. Understood, so all you really need to do is check your post before hitting submit reply and all will be good. Also try avoiding these double posts within a fee minutes and simply edit the first one in those cases. 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.
pixelsearch Posted February 6, 2025 Posted February 6, 2025 (edited) @angel83 could you try this ? expandcollapse popup#include <Array.au3> #include <File.au3> #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Opt("GUIResizeMode", $GUI_DOCKAUTO) Global $g_aFileList[0] $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|EXE 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,290) $AddButton = GUICtrlCreateButton("Add Subfolders", 90, 242, 85, 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 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $AddButton AddSubfolders1() Case $RemButton _GUICtrlListView_DeleteItemsSelected($hListView) Case $RemButton3 _GUICtrlListView_DeleteAllItems($hListView) Dim $g_aFileList[0] EndSwitch WEnd ;============================================== Func AddSubfolders1() Local $sBrowseFolder = FileSelectFolder ("Select Folder with Documents to merge", "", $FSF_EDITCONTROL, @ScriptDir) IF Not @error Then _AddSelectFolder($sBrowseFolder) EndIf EndFunc ;==>AddSubfolders1 ;============================================== Func _AddSelectFolder($_sFolderPath) Local $aFolderList = _FileListToArrayRec($_sFolderPath, "*.exe", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) If @error Then MsgBox($MB_TOPMOST, "_FileListToArrayRec", _ "error = " & @error & " extended = " & @extended & @crlf & _ (@extended = 9 ? "no files found" : "check AutoIt help file for this @extended error")) Return EndIf _ArrayConcatenate($g_aFileList, $aFolderList, 1) ; 1 = index of the first Source array entry $g_aFileList = _ArrayUnique($g_aFileList, Default, Default, Default, $ARRAYUNIQUE_NOCOUNT) Local $aFinal[Ubound($g_aFileList)][3] For $i = 0 To Ubound($aFinal) - 1 $aFinal[$i][1] = StringMid($g_aFileList[$i], StringInStr($g_aFileList[$i], "\", 0, -1) + 1) ; file name $aFinal[$i][2] = $g_aFileList[$i] ; path + file name Next _ArraySort($aFinal, 0, 0, 0, 1) ; last 1 = sort on column 1 (the 'file name' column) Local $sName_Old = "" For $i = 0 To Ubound($aFinal) - 1 $aFinal[$i][0] = $i + 1 If $sName_Old <> $aFinal[$i][1] Then $sName_Old = $aFinal[$i][1] Else ; same file name => blank it $aFinal[$i][1] = "" EndIf Next _GUICtrlListView_DeleteAllItems($hListView) _GUICtrlListView_AddArray($hListView, $aFinal) EndFunc ;==>_AddSelectFolder Edited February 6, 2025 by pixelsearch typo "I think you are searching a bug where there is no bug... don't listen to bad advice."
angel83 Posted February 7, 2025 Author Posted February 7, 2025 (edited) thanks friend pixelsearch, it worked for me, I thank you very much. Edited February 7, 2025 by angel83
angel83 Posted February 7, 2025 Author Posted February 7, 2025 I cannot solve the problem of finding the parent or main folder where the .exe executable is located. this is an example. when searching subfolders to find the executable.exe C:\file0\file1\file2 \file2-------main folder structure where the executable.exe is located file001 ------in this folder I also have the same executable with the same name file0002------in this folder I also have the same executable with the same name executable.exe -----this is the .exe program. I want to get it from folder 2 which is the main one and not from filexxx1 and filexxx2. any example to help me solve it? I hope I have explained it correctly.
pixelsearch Posted February 7, 2025 Posted February 7, 2025 (edited) Please have a look at the picture below, where the script retrieves correctly 4 times a file named "MyExecutable.exe" (in a parent folder + 3 subfolders) What should be changed in the display to suit your need ? Edit 1: how many lines should appear in the listview, 1 or 4 ? If you answer "only 1 line should appear in the listview, then please indicate which line it is. I guess it should be line 1, but then you'll never know that the file exists also in several subfolders... Edit 2: I found a link where you already asked this question So it seems you want to keep only 1 line (not 4) and it should be line #1 from the pic above, which indicates only the parent folder. Edited February 7, 2025 by pixelsearch "I think you are searching a bug where there is no bug... don't listen to bad advice."
pixelsearch Posted February 7, 2025 Posted February 7, 2025 (edited) You can try the script below, to display only 1 line per filename expandcollapse popup#include <Array.au3> #include <File.au3> #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Opt("GUIResizeMode", $GUI_DOCKAUTO) Global $g_aFileList[0] $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|EXE 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,290) $AddButton = GUICtrlCreateButton("Add Subfolders", 90, 242, 85, 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 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $AddButton AddSubfolders1() Case $RemButton _GUICtrlListView_DeleteItemsSelected($hListView) Case $RemButton3 _GUICtrlListView_DeleteAllItems($hListView) Dim $g_aFileList[0] EndSwitch WEnd ;============================================== Func AddSubfolders1() Local $sBrowseFolder = FileSelectFolder ("Select Folder with Documents to merge", "", $FSF_EDITCONTROL, @ScriptDir) IF Not @error Then _AddSelectFolder($sBrowseFolder) EndIf EndFunc ;==>AddSubfolders1 ;============================================== Func _AddSelectFolder($_sFolderPath) Local $aFolderList = _FileListToArrayRec($_sFolderPath, "*.exe", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) If @error Then MsgBox($MB_TOPMOST, "_FileListToArrayRec", _ "error = " & @error & " extended = " & @extended & @crlf & _ (@extended = 9 ? "no files found" : "check AutoIt help file for this @extended error")) Return EndIf _ArrayConcatenate($g_aFileList, $aFolderList, 1) ; 1 = index of the first Source array entry $g_aFileList = _ArrayUnique($g_aFileList, Default, Default, Default, $ARRAYUNIQUE_NOCOUNT) Local $aTemp[Ubound($g_aFileList)][3], $aFinal[Ubound($g_aFileList)][3], $sName_Old = "", $iCounter = -1 For $i = 0 To Ubound($aTemp) - 1 $aTemp[$i][1] = StringMid($g_aFileList[$i], StringInStr($g_aFileList[$i], "\", 0, -1) + 1) ; file name $aTemp[$i][2] = $g_aFileList[$i] ; path + file name $aTemp[$i][0] = $aTemp[$i][1] & "|" & $aTemp[$i][2] ; temporary column for sorting on 2 columns Next _ArraySort($aTemp) ; sort the 2D array on column 0 (which contains 'file name|path + file name') For $i = 0 To Ubound($aTemp) - 1 If $sName_Old <> $aTemp[$i][1] Then $iCounter += 1 ; 0+ $aFinal[$iCounter][0] = $iCounter + 1 $aFinal[$iCounter][1] = $aTemp[$i][1] $aFinal[$iCounter][2] = $aTemp[$i][2] $sName_Old = $aTemp[$i][1] EndIf Next If $iCounter < Ubound($aFinal) -1 Then ReDim $aFinal[$iCounter + 1][3] ; remove empty upper row(s) _GUICtrlListView_DeleteAllItems($hListView) _GUICtrlListView_AddArray($hListView, $aFinal) EndFunc ;==>_AddSelectFolder But I'm not satisfied with the result. For example if you have WinRAR.exe in 2 subfolders : WinRAR.exe | C:\Sources\WinRAR-10\WinRAR.exe WinRAR.exe | C:\Sources\WinRAR-MINE\WinRAR.exe Now when you add the folder "Sources" to the script, then only 1 line will be added to listview : WinRAR.exe | C:\Sources\WinRAR-10\WinRAR.exe How the script should know what line to display, maybe the display you need is : WinRAR.exe | C:\Sources\WinRAR-MINE\WinRAR.exe Only 1 line per filename will mask subfolders where the same filename exists. Anyway it's your choice, good luck Edited February 7, 2025 by pixelsearch "I think you are searching a bug where there is no bug... don't listen to bad advice."
angel83 Posted February 8, 2025 Author Posted February 8, 2025 (edited) Thanks for your time friend pixelsearch. but it didn't work for me. I think I found the problem after so many tries. is that when loading the subfolders it reads it alphabetically. If it finds a folder named a or 1, it will grab that folder first before the others. I hope I explained it correctly Edited February 8, 2025 by angel83
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