James Posted January 28, 2008 Posted January 28, 2008 Hi, I'm working on a project for my Mum's friends, "What's in my Zip?". I am using a modified version of danielkza's recurisve Zip search. To display his you need to use _ArrayDisplay(). I made my own script which has a list view so it looks neater: #include <GuiListView.au3> #include <GUIConstants.au3> $GUI = GUICreate("What's in my Zip?", 400, 300) GUICtrlCreateLabel("ZIP:", 10, 10) $Location = GUICtrlCreateInput("", 36, 6, 294) $MyZip = GUICtrlCreateButton("Open &Zip", 334, 4) $WhatsInMyZip = GUICtrlCreateListView("What's in my Zip?", 10, 30, 380, 260) GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $MyZip _GUICtrlListView_DeleteAllItems($WhatsInMyZip) $ZIP = FileOpenDialog("What's in my Zip?", @HomeDrive, ".ZIP (*.ZIP)") GUICtrlSetData($Location, $ZIP) $Link = _ZipRecursiveSearch($ZIP) ;_GUICtrlListView_AddArray($WhatsInMyZip, $Link) EndSwitch WEnd I basically need to put in the data into the list view. I know this is really easy but I only just woke up. Thanks, James Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
rasim Posted January 28, 2008 Posted January 28, 2008 Hello JamesB! I`m intersting a _ZipRecursiveSearch() function, please show this function. And i bad understand, what you need. You need put array in to ListView as elements?
James Posted January 28, 2008 Author Posted January 28, 2008 Yeah, well I just need to get the normal _ZipRecursiveSearch to work at the moment so then I can make the function quickly. The data you can see in the _ArrayDisplay() I need to put it into my own listiew. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
rasim Posted January 28, 2008 Posted January 28, 2008 Yeah, well I just need to get the normal _ZipRecursiveSearch to work at the moment so then I can make the function quickly. The data you can see in the _ArrayDisplay() I need to put it into my own listiew. JamesB sorry, but you don`t show me _ZipRecursiveSearch function, as i`m see something in _ArrayDisplay()? . Function really exist or exist in your brain? What the problem with puting data in ListView? Sorry, i don`t teach you, just look in the help file on: GUICtrlCreateListViewItem() _GUICtrlListView_AddItem() _GUICtrlListView_AddSubItem() _GUICtrlListView_InsertItem()
James Posted January 28, 2008 Author Posted January 28, 2008 Here you go!I know the commands to put them into the listview. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
rasim Posted January 28, 2008 Posted January 28, 2008 This? expandcollapse popup#include <GuiListView.au3> #include <GUIConstants.au3> $GUI = GUICreate("What's in my Zip?", 400, 300) GUICtrlCreateLabel("ZIP:", 10, 10) $Location = GUICtrlCreateInput("", 36, 6, 294) $MyZip = GUICtrlCreateButton("Open &Zip", 334, 4) $WhatsInMyZip = _GUICtrlListView_Create($GUI, "What's in my Zip?", 10, 30, 380, 260) GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $MyZip _GUICtrlListView_DeleteAllItems($WhatsInMyZip) $ZIP = FileOpenDialog("What's in my Zip?", @HomeDrive, ".ZIP (*.ZIP)") If Not @error Then GUICtrlSetData($Location, $ZIP) AddZipFiles($ZIP) EndIf EndSwitch WEnd Func AddZipFiles($iZip) Local $Link, $i $Link = _ZipRecursiveSearch($ZIP) If IsArray($Link) Then For $i = 1 To $Link[0] _GUICtrlListView_AddItem($WhatsInMyZip, $Link[$i]) Next EndIf EndFunc Func _ZipRecursiveSearch($StartDir, $Pattern = ".", $Recurse = True, $Depth = 0) ; We need to store a global start directory because $oItem.Path includes folders If $Depth = 0 Then Global $ZipSearchStartDir = $StartDir EndIF ; Create Shell object Local $oShell = ObjCreate('Shell.Application') If @error or not IsObj($oShell) Then Return ; Create Folder object Local $oDir = $oShell.NameSpace($StartDir) If @error or not IsObj($oDir) Then Return ; Create FolderItems object Local $oItems = $oDir.Items() If @error or not IsObj($oItems) Then Return ; If it is the first iteration,create the global array If $Depth = 0 Then Global $ZipSearchArray[1] EndIf ; The $i is need because $oItems.Item needs an index Local $i=0 While 1 ; Get FolderItem object $oItem = $oItems.Item($i) If @error Or Not IsObj($oItem) Then ExitLoop ; Get $Item 's path $NextFile = $oItem.Path() ; If it's a folder, recurse If $oItem.IsFolder() Then If $Recurse Then _ZipRecursiveSearch($ZipSearchStartDir & "\" & $NextFile,$Pattern,True,$Depth+1) ; If not,add file to the array Else If StringRegExp($NextFile,$Pattern,0) Then ; Increment file counter $ZipSearchArray[0]+=1 ; I know ReDim is slow,but there isn't something like GetDirSize for the zip files ReDim $ZipSearchArray[$ZipSearchArray[0]+1] ; Actually add file to the array $ZipSearchArray[$ZipSearchArray[0]] = $ZipSearchStartDir & $NextFile EndIf EndIf ; Increment index counter $i+=1 WEnd If $Depth = 0 Then ; Delete Start directory from every element,because it creates confusion with zip files For $i=1 To $ZipSearchArray[0] $ZipSearchArray[$i] = StringReplace($ZipSearchArray[$i],$StartDir,"") Next ; Return array to the user Return $ZipSearchArray EndIf EndFunc
James Posted January 28, 2008 Author Posted January 28, 2008 I shall try that when I get home. Thanks rasim! It makes so much sense now lol. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
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