Wb-FreeKill Posted May 21, 2005 Share Posted May 21, 2005 (edited) The last two days ive tried to make a browsing tool with TreeView.. like when browswing in regedit, this is what ive made so far. Maybe it's messy, it may not be.. give your opinion or advice to do this better.. it is not finish at all, but i can't get any further... EDIT: Script updated - Thanks Holger expandcollapse popup#Include <GUIConstants.au3> Global $Tree Global $SubTree GUICreate("BrowseDemo",400,400) $TreeView = GUICtrlCreateTreeView(20,20,200,300) GUICtrlSetImage(-1,"shell32.dll",3,4) GUICtrlSetImage(-1,"shell32.dll",4,2) FileDelete("Files.ini") $HDDrives = DrivegetDrive("FIXED") For $i = 1 To $HDDrives[0] Search($HDDrives[$i] & "\","*.*") $var = IniReadSection("Files.ini", $HDDrives[$i] & "\") For $h = 1 To $var[0][0] $IniRead = IniRead("Files.ini",$HDDrives[$i] & "\",$h,"NotFound") _Next($IniRead,"*.*",$h) Next Next GUISetState() While 1;Main Loop $msg = GUIGetmsg() If $msg = $GUI_EVENT_CLOSE Then Exit WEnd ;Functions ;/////////////////////////////////////////// Func Search($SearchPath,$FileType) $Item1 = GUICtrlCreateTreeViewItem(StringUpper($SearchPath),$TreeView) GUICtrlSetImage(-1,"shell32.dll",8) $Search = FileFindFirstFile($SearchPath & $FileType) If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf $Count = 1 DIM $Tree[99999] While 1 $File = FileFindNextFile($search) If @error Then ExitLoop $Attrib = FileGetAttrib($SearchPath & $File) If StringInStr($Attrib,"D") Then $Tree[$Count] = GUICtrlCreateTreeViewItem($File,$Item1) IniWrite("Files.ini",$SearchPath,$Count,$SearchPath & $File & "\") $Count = $Count +1 EndIf WEnd FileClose($Search) EndFunc Func _Next($SearchPath,$FileType,$Number) $Search1 = FileFindFirstFile($SearchPath & $FileType) If $search1 = -1 Then Else $Count = 1 DIM $SubTree[99999] While 1 $NextFile = FileFindNextFile($search1) If @error Then ExitLoop $Attrib = FileGetAttrib($SearchPath & $NextFile) If $Attrib = "D" Then;StringInStr($Attrib,"D") Then If $NextFile = "." Or $NextFile = ".." Then Else $FBuffer = $SearchPath & $NextFile & "\" $SubTree[$Count] = GUICtrlCreateTreeViewItem($NextFile,$Tree[$Number]) $Search2 = FileFindFirstFile($FBuffer & "*.*") If $search2 = -1 Then msgbox(0,"","Ingen mapper") Else $Count1 = 1 While 1 $NextFile2 = FileFindNextFile($search2) If @error Then ExitLoop $Attrib = FileGetAttrib($FBuffer & $NextFile2) If $Attrib = "D" Then;StringInStr($Attrib,"D") Then If $NextFile2 = "." Or $NextFile2 = ".." Then Else GUICtrlCreateTreeViewItem($NextFile2,$SubTree[$Count]) $Count1 = $Count1 +1 EndIf EndIf WEnd FileClose($Search2) EndIf ;msgbox(0,"","Stop " & $Count) $Count = $Count +1 EndIf EndIf WEnd FileClose($Search1) EndIf EndFUnc Edited May 21, 2005 by Wb-FreeKill Link to comment Share on other sites More sharing options...
fmen Posted May 21, 2005 Share Posted May 21, 2005 Great work. I like the ini file idea. If you were able to add the folder sizes in MB's to the ini file, I for one would find the script very useful. Link to comment Share on other sites More sharing options...
Wb-FreeKill Posted May 21, 2005 Author Share Posted May 21, 2005 Great work. I like the ini file idea. If you were able to add the folder sizes in MB's to the ini file, I for one would find the script very useful.<{POST_SNAPBACK}>The idea is when you select a folder in the tree, a window at the right side should show all containing files, incl all information.. The problem is, i can't get it keep searching the folder and subfoldes until nothing is found. Then go back and proceed with the next folder in the tree until it found all the foldes (not files) and then show gui...Any help would be great Link to comment Share on other sites More sharing options...
Holger Posted May 21, 2005 Share Posted May 21, 2005 Looks very good Maybe just a little bit more color with:... $TreeView = GUICtrlCreateTreeView(20,20,200,300) GUICtrlSetImage(-1,"shell32.dll",3,4) GUICtrlSetImage(-1,"shell32.dll",4,2) ... Func Search($SearchPath,$FileType) $Item1 = GUICtrlCreateTreeViewItem(StringUpper($SearchPath),$TreeView) GUICtrlSetImage(-1,"shell32.dll",8) ...Maybe I should put more energy in programming of my 'old' DirList/DirTree-project, but only after finishing the color'ed menu/icons. And this I only will continue it next week.If you take a small look you can find my old sample-compiled-exe here:http://www.hiddensoft.com/fileman/users/pu...it3Explorer.exeSo long Holger Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView Link to comment Share on other sites More sharing options...
Wb-FreeKill Posted May 21, 2005 Author Share Posted May 21, 2005 (edited) lol damn nice Holger - thank you! EDIT: your script is exactly what i want to do, did you code this in AutoIt?.. if so - could i get the source, or any example of how to code it? Edited May 21, 2005 by Wb-FreeKill Link to comment Share on other sites More sharing options...
Holger Posted May 21, 2005 Share Posted May 21, 2005 @Wb-FreeKill: No, this is not AutoIt3-Code - it's based up 2 new controls for GUI that I started to develope some month ago (DirTree/DirList). The last few month I didn't work on it but I will continue like I said after I finished the implementing of icons an colors in menus/menuitems for GUI/Tray So long... Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView Link to comment Share on other sites More sharing options...
Wb-FreeKill Posted May 21, 2005 Author Share Posted May 21, 2005 @Wb-FreeKill: No, this is not AutoIt3-Code - it's based up 2 new controls for GUI that I started to develope some month ago (DirTree/DirList).The last few month I didn't work on it but I will continue like I said after I finished the implementing of icons an colors in menus/menuitems for GUI/Tray So long...<{POST_SNAPBACK}>okay great... Link to comment Share on other sites More sharing options...
Cyclops Posted May 26, 2005 Share Posted May 26, 2005 Hi,cool Script i was looking for something like that... thx! Lets try to realize your idea:The idea is when you select a folder in the tree, a window at the right side should show all containing files, incl all information..When GuiCtrlRead the treeview there is the controlid of the selected Folder... (Selecting "C:\" Returns "4") When you run the search again witout creating the GUI entries it must be possible to find the folder? Hope you understand my bad english...Here an Example (using quote, so you can see what i mean)Func Searchagain($SearchPath,$FileType)$Item1 = GUICtrlCreateTreeViewItem(StringUpper($SearchPath),$TreeView)GUICtrlSetImage(-1,"shell32.dll",8)$Search = FileFindFirstFile($SearchPath & $FileType) If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") ExitEndIf$Count = 1DIM $Tree[99999]While 1 $File = FileFindNextFile($search) If @error Then ExitLoop $Attrib = FileGetAttrib($SearchPath & $File) If StringInStr($Attrib,"D") Then If GUICtrlRead ($treeview) = $count Then MsgBox(0,"Selected Folder",$SearchPath & $File & "\") IniWrite("Files.ini",$SearchPath,$Count,$SearchPath & $File & "\") $Count = $Count +1 EndIfWEndFileClose($Search)EndFunccyclops Sorry for my cruel english :D Link to comment Share on other sites More sharing options...
ioliver Posted May 26, 2005 Share Posted May 26, 2005 Great Job FreeKill. Seems to work well. Ian "Blessed be the name of the Lord" - Job 1:21Check out Search IMF Link to comment Share on other sites More sharing options...
Cyclops Posted May 27, 2005 Share Posted May 27, 2005 Hey, i worked on that script and here is my version with a list for the files in selcted folder: expandcollapse popup#Include <GUIConstants.au3> Global $Tree Global $SubTree ; Create GUI GUICreate("BrowseDemo",430,325) $TreeView = GUICtrlCreateTreeView(10,10,200,305) GUICtrlSetImage(-1,"shell32.dll",3,4) GUICtrlSetImage(-1,"shell32.dll",4,2) $list = GUICtrlCreateList("",220,10,200,310) FileDelete("Files.ini") $test = FileOpen ("test.txt",2) $HDDrives = DrivegetDrive("FIXED") For $i = 1 To $HDDrives[0] FileWriteLine ($test,$HDDrives[$i] & "\") Search($HDDrives[$i] & "\","*.*") $var = IniReadSection("Files.ini", $HDDrives[$i] & "\") For $h = 1 To $var[0][0] $IniRead = IniRead("Files.ini",$HDDrives[$i] & "\",$h,"NotFound") _Next($IniRead,"*.*",$h) Next Next ; Close the search handle FileClose($test) $test = FileOpen ("test.txt",0) GUISetState() $a = _Search4Files(FileReadLine ($test,GUICtrlRead ($treeview)-4)) AdlibEnable ("check") While 1;Main Loop $msg = GUIGetmsg() If $msg = $GUI_EVENT_CLOSE Then Exit WEnd Exit ;Functions ;/////////////////////////////////////////// Func Search($SearchPath,$FileType) $Item1 = GUICtrlCreateTreeViewItem(StringUpper($SearchPath),$TreeView) GUICtrlSetImage(-1,"shell32.dll",8) $Search = FileFindFirstFile($SearchPath & $FileType) If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf $Count = 1 DIM $Tree[99999] While 1 $File = FileFindNextFile($search) If @error Then ExitLoop $Attrib = FileGetAttrib($SearchPath & $File) If StringInStr($Attrib,"D") Then $Tree[$Count] = GUICtrlCreateTreeViewItem($File,$Item1) FileWriteLine ($test,$SearchPath & $File & "\") IniWrite("Files.ini",$SearchPath,$Count,$SearchPath & $File & "\") $Count = $Count +1 EndIf WEnd FileClose($Search) EndFunc Func _Next($SearchPath,$FileType,$Number) $Search1 = FileFindFirstFile($SearchPath & $FileType) If $search1 = -1 Then Else $Count = 1 DIM $SubTree[99999] While 1 $NextFile = FileFindNextFile($search1) If @error Then ExitLoop $Attrib = FileGetAttrib($SearchPath & $NextFile) If $Attrib = "D" Then;StringInStr($Attrib,"D") Then If $NextFile = "." Or $NextFile = ".." Then Else $FBuffer = $SearchPath & $NextFile & "\" $SubTree[$Count] = GUICtrlCreateTreeViewItem($NextFile,$Tree[$Number]) FileWriteLine ($test,$FBuffer) $Search2 = FileFindFirstFile($FBuffer & "*.*") If $search2 = -1 Then msgbox(0,"","Ingen mapper") Else $Count1 = 1 While 1 $NextFile2 = FileFindNextFile($search2) If @error Then ExitLoop $Attrib = FileGetAttrib($FBuffer & $NextFile2) If $Attrib = "D" Then;StringInStr($Attrib,"D") Then If $NextFile2 = "." Or $NextFile2 = ".." Then Else GUICtrlCreateTreeViewItem($NextFile2,$SubTree[$Count]) FileWriteLine ($test,$FBuffer & $NextFile2& "\") $Count1 = $Count1 +1 EndIf EndIf WEnd FileClose($Search2) EndIf ;msgbox(0,"","Stop " & $Count) $Count = $Count +1 EndIf EndIf WEnd FileClose($Search1) EndIf EndFUnc Func check() $b = GUICtrlRead ($treeview) If $a <> $b Then $a = _Search4Files(FileReadLine ($test,GUICtrlRead ($treeview)-4)) EndFunc Func _Search4Files($path) GUICtrlSetData($list, "") $search4 = FileFindFirstFile($path & "*.*") If $search4 <> -1 Then While 1 $file = FileFindNextFile($search4) If @error Then ExitLoop If $file = "." Then $file = FileFindNextFile($search4) If $file = ".." Then $file = FileFindNextFile($search4) If StringInStr(FileGetAttrib ($path & $file), "D") = 0 Then GUICtrlSetData($list, $file) WEnd EndIf Return GUICtrlRead ($treeview) FileClose($search4) EndFunc Sorry for my cruel english :D Link to comment Share on other sites More sharing options...
Valuater Posted May 27, 2005 Share Posted May 27, 2005 Nice work......... Wb-FreeKill and Cyclops Link to comment Share on other sites More sharing options...
busysignal Posted May 27, 2005 Share Posted May 27, 2005 I agree... Nice work. This little project keeps looking better and better. Soon you maybe could create a UDF out of it.. Cheers... Link to comment Share on other sites More sharing options...
Wb-FreeKill Posted May 27, 2005 Author Share Posted May 27, 2005 Nice work cyclops! but we still have the problem with keep searching in each folder.. ill hope someone better than me could take a look at this? Link to comment Share on other sites More sharing options...
Cyclops Posted May 28, 2005 Share Posted May 28, 2005 (edited) What do you mean? Sorry, i am a german boy ^^Another Problem is that when a new folder is created you didn't find him in that browser until he is restarted....CyclopsP.S.:I agree... Nice work. This little project keeps looking better and better. Soon you maybe could create a UDF out of it.. Cheers... <{POST_SNAPBACK}>I hope so! Edited May 28, 2005 by Cyclops Sorry for my cruel english :D 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