Raffle Posted September 29, 2010 Share Posted September 29, 2010 expandcollapse popup; A Daimonin Skin switcher for win32 By Ross Dimassimo (Raf) #NoTrayIcon #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <Constants.au3> #include <WinAPI.au3> #include "Zip.au3" Opt('MustDeclareVars', 1) _Main() GetWindowsVer() DownloadSkin($Url, $Skin) DownloadMusic($Url, $Music) CreateShortcuts($Skin, $Ver) UnzipMusic($Music) CheckMusicDir($MusicDirChk) Func _Main() Global $DaiDirectory, $DaiDirectoryExists, $DaiDirectoryInput, $Ver, $Url, $Skin, $Desktop, $QuickBar, $StartMenu, $Status, $Music, $MusicDirChk Global $StatusLabel Local $Triton, $BlackMetal, $RoyalBlue, $ClassicGray, $Default, $MusicAll, $MusicLow, $MusicMedium, $MusicHigh, $MusicNone, $msg GUICreate("Daimonin Skin Changer by Raf", 370, 160) $Desktop = GUICtrlCreateCheckbox("Make Desktop Shortcut", 10, 5) $StartMenu = GUICtrlCreateCheckbox("Make Start Menu Shortcut", 10, 25) $QuickBar = GUICtrlCreateCheckbox("Make Quick Bar Shortcut", 10, 45) $Triton = GUICtrlCreateButton("Triton", 10, 100, 70, 20) $BlackMetal = GUICtrlCreateButton("BlackMetal", 80, 100, 70, 20) $RoyalBlue = GUICtrlCreateButton("RoyalBlue", 150, 100, 70, 20) $ClassicGray = GUICtrlCreateButton("ClassicGray", 220, 100, 70, 20) $Default = GUICtrlCreateButton("Default", 290, 100, 70, 20) $MusicAll = GUICtrlCreateButton("All Music", 10, 120, 70, 20) $MusicHigh = GUICtrlCreateButton("High Music", 80, 120, 70, 20) $MusicMedium = GUICtrlCreateButton("Medium Music", 150, 120, 70, 20) $MusicLow = GUICtrlCreateButton("Low Music", 220, 120, 70, 20) $MusicNone = GUICtrlCreateButton("No Music", 290, 120, 70, 20) GUICtrlCreateLabel("Daimonin Path:", 10, 75) $DaiDirectoryExists = FileExists("\daimonin") If $DaiDirectoryExists = 1 Then $DaiDirectoryInput = GUICtrlCreateInput("C:\daimonin", 90, 75, 120, 20) GUICtrlCreateLabel("Directory Exists!", 215, 75) Else $DaiDirectoryInput = GUICtrlCreateInput("", 90, 75, 120, 20) EndIf $Status = "Ready" $StatusLabel = GUICtrlCreateLabel($Status, 0, 144, 370, 16, BitOR($SS_SIMPLE, $SS_SUNKEN)) GUISetState() ; display the GUI Do $msg = GUIGetMsg() $Ver = GetWindowsVer() $DaiDirectory = GUICtrlRead( $DaiDirectoryInput) $DaiDirectory = $Daidirectory & "\client" Select Case $msg = $Triton DownloadSkin("http://www.daimonin.org/sites/default/files/media/artists/Addons/Skins/Triton.zip", "Triton") CreateShortcuts("Triton",$Ver) Case $msg = $BlackMetal DownloadSkin("http://www.daimonin.org/sites/default/files/media/artists/Addons/Skins/BlackMetal.zip", "BlackMetal") CreateShortcuts("BlackMetal",$Ver) Case $msg = $RoyalBlue DownloadSkin("http://www.daimonin.org/sites/default/files/media/artists/Addons/Skins/RoyalBlue.zip","RoyalBlue") CreateShortcuts("RoyalBlue",$Ver) Case $msg = $ClassicGray DownloadSkin("http://www.daimonin.org/sites/default/files/media/artists/Addons/Skins/ClassicGrey.zip", "ClassicGray") CreateShortcuts("ClassicGray",$Ver) Case $msg = $Default CreateShortcuts("Default",$Ver) Case $msg = $MusicAll DownloadMusic("http://downloads.sourceforge.net/project/daimonin/Addon%20packs/Music/AllMusic.zip?r=http%3A%2F%2Fwww.daimonin.org%2Fdaipedia%2FAddonPacks&ts=1285768250&use_mirror=softlayer","AllMusic") UnzipMusic("AllMusic") Case $msg = $MusicHigh DownloadMusic("http://downloads.sourceforge.net/project/daimonin/Addon%20packs/Music/HighLevels.zip?r=http%3A%2F%2Fwww.daimonin.org%2Fdaipedia%2FAddonPacks&ts=1285768623&use_mirror=superb-sea2","HighLevels") UnzipMusic("HighLevels") Case $msg = $MusicMedium DownloadMusic("http://downloads.sourceforge.net/project/daimonin/Addon%20packs/Music/MediumLevels.zip?r=http%3A%2F%2Fwww.daimonin.org%2Fdaipedia%2FAddonPacks&ts=1285768592&use_mirror=superb-sea2","MediumLevels") UnzipMusic("MediumLevels") Case $msg = $MusicLow DownloadMusic("http://downloads.sourceforge.net/project/daimonin/Addon%20packs/Music/LowLevels.zip?r=http%3A%2F%2Fwww.daimonin.org%2Fdaipedia%2FAddonPacks&ts=1285768539&use_mirror=iweb","LowLevels") UnzipMusic("LowLevels") Case $msg = $MusicNone UnzipMusic("MusicNone") Case $msg = $GUI_EVENT_CLOSE EndSelect Until $msg = $GUI_EVENT_CLOSE EndFunc ;==>_Main Func GetWindowsVer() return @OSVersion EndFunc Func DownloadSkin ($Url, $Skin) local $SkinDir = $DaiDirectory & "\daiskin\skins\" If FileExists($SkinDir) = 0 Then DirCreate($SkinDir) EndIf Local $File = $SkinDir & $skin & ".zip" Local $Size = InetGetSize($url) If FileExists($File) = 0 Then Local $Download = InetGet($url, $File, 1, 1) Do Local $Data = InetGetInfo($Download) If $Data[0] / 1000 < 1000 Then $Status = $Skin & " Skin Download: " & Round($Data[0] / 1000, 2) & " / " & Round($Size / 1000, 2) & " KB" Else $Status = $Skin & " Skin Download: " & Round($Data[0] / 1000 / 1000,1) & " / " & Round($Size / 1000 / 1000,1) & " MB" EndIf GUICtrlSetData($StatusLabel, $Status) sleep(1) Until InetGetInfo($Download, 2) $Status = $Skin & " Skin Downloaded, Installing Shortcuts.." GUICtrlSetData($StatusLabel, $Status) EndIf EndFunc Func DownloadMusic($Url, $Music) local $MusicDirDownloadMusic = $DaiDirectory & "\daiskin\music\" If FileExists($MusicDirDownloadMusic) = 0 Then DirCreate($MusicDirDownloadMusic) EndIf Local $File = $MusicDirDownloadMusic & $Music & ".zip" Local $Size = InetGetSize($url) If FileExists($File) = 0 Then Local $Download = InetGet($url, $File, 1, 1) Do Local $Data = InetGetInfo($Download) If $Data[0] / 1000 < 1000 Then $Status = $Music & " Music Download: " & Round($Data[0] / 1000, 2) & " / " & Round($Size / 1000, 2) & " KB" Else $Status = $Music & " Music Download: " & Round($Data[0] / 1000 / 1000,1) & " / " & Round($Size / 1000 / 1000,1) & " MB" EndIf GUICtrlSetData($StatusLabel, $Status) sleep(1) Until InetGetInfo($Download, 2) $Status = $Music & "Music Downloaded, Unzipping.." GUICtrlSetData($StatusLabel, $Status) EndIf EndFunc Func DownloadMusicNone() local $MusicDirDownloadNone = $DaiDirectory & "\daiskin\music\" Local $File = $MusicDirDownloadNone & "media.zip" Local $Size = InetGetSize("http://daiskin.foo.mx/media.zip") If FileExists($File) = 0 Then Local $Download = InetGet("http://daiskin.foo.mx/media.zip", $File, 1, 1) Do Local $Data = InetGetInfo($Download) If $Data[0] / 1000 < 1000 Then $Status = $Music & " Base Music Download: " & Round($Data[0] / 1000, 2) & " / " & Round($Size / 1000, 2) & " KB" Else $Status = $Music & " Base Music Download: " & Round($Data[0] / 1000 / 1000,1) & " / " & Round($Size / 1000 / 1000,1) & " MB" EndIf GUICtrlSetData($StatusLabel, $Status) sleep(1) Until InetGetInfo($Download, 2) $Status = $Music & "Music Downloaded, Unzipping.." GUICtrlSetData($StatusLabel, $Status) EndIf EndFunc Func CreateShortcuts($Skin, $Ver) local $Addon local $SkinZip If $Skin = "Default" Then $Addon = "" $SkinZip = "" Else $Addon = "--addon=daiskin\skins\" $SkinZip = $Skin & ".zip" EndIf local $DaiLocation = $DaiDirectory & "\daimonin.exe" local $XpQuickBarDir = @HomeDrive & "\Documents and Settings\" & @UserName & "\Application Data\Microsoft\Internet Explorer\Quick Launch\Daimonin Client" local $XpStartMenu = @HomeDrive & "\Documents and Settings\All Users\Start Menu\Programs\Daimonin\Daimonin Client" local $7QuickBarDir = @HomeDrive & "\Users\" & @UserName & "\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Daimonin" local $7StartMenu = @HomeDrive & "\ProgramData\Microsoft\Windows\Start Menu\Programs\Daimonin\Daimonin Client" If $Ver = "WIN_XP" Then If BitAnd(GUICtrlRead($Desktop),$GUI_CHECKED) Then $Status = "Installing " & $Skin & " Desktop Shortcut.." GUICtrlSetData($StatusLabel, $Status) FileCreateShortcut($DaiLocation,@DesktopDir & "\Daimonin",$DaiDirectory, $Addon & $SkinZip, $Skin & "Skin Shortcut") EndIf If BitAnd(GUICtrlRead($StartMenu),$GUI_CHECKED) Then $Status = "Installing " & $Skin & " Start Menu Shortcut.." GUICtrlSetData($StatusLabel, $Status) FileCreateShortcut($DaiLocation,$XpStartMenu,$DaiDirectory, $Addon & $SkinZip, $Skin & "Skin Shortcut") EndIf If BitAnd(GUICtrlRead($QuickBar),$GUI_CHECKED) Then $Status = "Installing " & $Skin & " Quick Bar Shortcut.." GUICtrlSetData($StatusLabel, $Status) FileCreateShortcut($DaiLocation,$XpQuickBarDir,$DaiDirectory, $Addon & $SkinZip, $Skin & "Skin Shortcut") EndIf EndIf If $Ver = "WIN_7" OR "Win_VISTA" Then If BitAnd(GUICtrlRead($Desktop),$GUI_CHECKED) Then $Status = "Installing " & $Skin & " Desktop Shortcut.." GUICtrlSetData($StatusLabel, $Status) FileCreateShortcut($DaiLocation,@DesktopDir & "\Daimonin",$DaiDirectory, $Addon & $SkinZip, $Skin & "Skin Shortcut") EndIf If BitAnd(GUICtrlRead($StartMenu),$GUI_CHECKED) Then $Status = "Installing " & $Skin & " Start Menu Shortcut.." GUICtrlSetData($StatusLabel, $Status) FileCreateShortcut($DaiLocation,$7StartMenu,$DaiDirectory, $Addon & $SkinZip, $Skin & "Skin Shortcut") EndIf If BitAnd(GUICtrlRead($QuickBar),$GUI_CHECKED) Then $Status = "Installing " & $Skin & " Quick Bar Shortcut.." GUICtrlSetData($StatusLabel, $Status) If $ver = "Win_7" Then _PinTaskbar($DaiLocation) EndIf FileCreateShortcut($DaiLocation,$7QuickBarDir,$DaiDirectory, $Addon & $SkinZip, $Skin & "Skin Shortcut") EndIf EndIf $Status = $Skin & " Skin Installed" GUICtrlSetData($StatusLabel, $Status) EndFunc Func UnzipMusic($Music) local $DaiMusicDir = $DaiDirectory & "\daiskin\music\" local $MusicDir = $DaiDirectory local $MusicDirDelete = $MusicDir & "\media" local $MusicDirTypex = CheckMusicDir($MusicDirDelete) If FileExists($DaiMusicDir & "media") = 0 Then If $MusicDirTypex = "MusicNone" Then FileCopy($MusicDir, $DaiMusicDir & "media") Else $Status = "Downloading Clean media Folder" GUICtrlSetData($StatusLabel, $Status) DownloadMusicNone() $Status = "Unpacking Clean media Folder" GUICtrlSetData($StatusLabel, $Status) _Zip_UnzipAll($DaiMusicDir & "media.zip", $DaiMusicDir) EndIf EndIf If $Music = $MusicDirTypex Then $Status = $Music & " Is Already Installed" GUICtrlSetData($StatusLabel, $Status) Else If $Music = "MusicNone" Then $Status = "Deleting Bad media Folder" GUICtrlSetData($StatusLabel, $Status) FileDelete($MusicDirDelete) $Status = "Installing " & $Music GUICtrlSetData($StatusLabel, $Status) _Zip_UnzipAll($DaiMusicDir & "media.zip", $DaiDirectory) $Status = $Music & " Is Installed" GUICtrlSetData($StatusLabel, $Status) Else $Status = "Deleting Bad media Folder" GUICtrlSetData($StatusLabel, $Status) FileDelete($MusicDirDelete) $Status = "Unpacking " & $Music GUICtrlSetData($StatusLabel, $Status) If $Music = "AllMusic" Then $MusicDir = $DaiDirectory & "\media" EndIf _Zip_UnzipAll($DaiMusicDir & $Music & ".zip", $MusicDir) FileCopy($DaiMusicDir & "media\orchestral.ogg",$DaiDirectory & "\media\orchestral.ogg") $Status = $Music & " Successfully Installed" GUICtrlSetData($StatusLabel, $Status) EndIf EndIf EndFunc Func CheckMusicDir($MusicDirChk) local $MusicDirSize = DirGetsize($MusicDirChk) local $MusicDirtype If $MusicDirSize = "950684" Then $MusicDirType = "MusicNone" ElseIf $MusicDirSize = "88180097" Then $MusicDirType = "AllMusic" ElseIf $MusicDirSize = "35210667" Then $MusicDirType = "HighLevels" ElseIf $MusicDirSize = "26533938" Then $MusicDirType = "MediumLevels" ElseIf $MusicDirSize = "28336860" Then $MusicDirType = "LowLevels" Else $MusicDirType = "Unknown" EndIf Return $MusicDirType EndFunc Func _PinTaskbar($File, $Pin = True) If @OSBuild < 7600 Then Return SetError(1) ; Windows 7 only If Not FileExists($File) Then Return SetError(2) local $sFolder = StringRegExpReplace($File, "(^.*\\)(.*)", "\1") local $sFile = StringRegExpReplace($File, "^.*\\", "") local $oShell = ObjCreate("Shell.Application") local $oFolder = $oShell.NameSpace($sFolder) local $oFolderItem = $oFolder.ParseName($sFile) local $oFolderItemVerbs = $oFolderItem.Verbs local $hInstance = _WinAPI_LoadLibraryEx("shell32.dll", $LOAD_LIBRARY_AS_DATAFILE) local $DoVerb = '' If $hInstance Then If $Pin = 1 Then local $DoVerb = _WinAPI_LoadString($hInstance, 5386) Else local $DoVerb = _WinAPI_LoadString($hInstance, 5387) EndIf _WinAPI_FreeLibrary($hInstance) EndIf If $DoVerb = '' Then Return SetError(3) ; $DoVerb string couldn't received For $i = 0 To $oFolderItemVerbs.Count - 1 If $oFolderItemVerbs.Item($i).Name = $DoVerb Then $oFolderItemVerbs.Item($i).DoIt Return EndIf Next Return SetError(4) ; $DoVerb string not in menu EndFunc expandcollapse popup;#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <array.au3> ; ------------------------------------------------------------------------------ ; ; AutoIt Version: 3.2 ; Language: English ; Description: ZIP Functions. ; Author: torels_ ; ; ------------------------------------------------------------------------------ Global $oApp, $hWnd If UBound($CMDLine) > 1 Then If $CMDLine[1] <> "" Then _Zip_VirtualZipOpen() EndIf ;=============================================================================== ; ; Function Name: _Zip_Create() ; Description: Create Empty ZIP file. ; Parameter(s): $hFilename - Complete path to zip file that will be created ; Requirement(s): none. ; Return Value(s): Returns the Zip file path (to be used as a handle - even though it's not necessary) ; Author(s): torels_ ; ;=============================================================================== Func _Zip_Create($hFilename) $hFp = FileOpen($hFilename, 26) $sString = Chr(80) & Chr(75) & Chr(5) & Chr(6) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) FileWrite($hFp, $sString) If @error Then Return SetError(1,0,0) FileClose($hFp) While Not FileExists($hFilename) Sleep(10) Wend Return $hFilename EndFunc ;==>_Zip_Create ;=============================================================================== ; ; Function Name: _Zip_AddFile() ; Description: Add a file to a ZIP Archieve. ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; $hFile2Add - Complete path to the file that will be added ; $flag = 1 ; - 0 ProgressBox ; - 1 no progress box ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1~3 ; @error = 1 no Zip file ; @error = 2 no dll ; @error = 3 dll isn't registered ; On Failure - Returns False ; Author(s): torels_ ; Notes: The return values will be given once the compressing process is ultimated... it takes some time with big files ; ;=============================================================================== Func _Zip_AddFile($hZipFile, $hFile2Add, $flag = 1) Local $DLLChk = _Zip_DllChk() Local $files = _Zip_Count($hZipFile) If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0);no dll If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file $oApp = ObjCreate("Shell.Application") $copy = $oApp.NameSpace($hZipFile).CopyHere($hFile2Add) While 1 If $flag = 1 then _Hide() If _Zip_Count($hZipFile) = ($files+1) Then ExitLoop Sleep(10) WEnd Return SetError(0,0,1) EndFunc ;==>_Zip_AddFile ;=============================================================================== ; ; Function Name: _Zip_AddFolder() ; Description: Add a folder to a ZIP Archieve. ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; $hFolder - Complete path to the folder that will be added (possibly including "\" at the end) ; $flag = 1 ; - 1 no progress box ; - 0 progress box ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1~3 ; @error = 1 no Zip file ; @error = 2 no dll ; @error = 3 dll isn't registered ; Author(s): torels_ ; Notes: The return values will be given once the compressing process is ultimated... it takes some time with big files ; ;=============================================================================== Func _Zip_AddFolder($hZipFile, $hFolder, $flag = 1) Local $DLLChk = _Zip_DllChk() If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0);no dll If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file If StringRight($hFolder, 1) <> "\" Then $hFolder &= "\" $files = _Zip_Count($hZipFile) $oApp = ObjCreate("Shell.Application") $oCopy = $oApp.NameSpace($hZipFile).CopyHere($oApp.Namespace($hFolder)) While 1 If $flag = 1 then _Hide() If _Zip_Count($hZipFile) = ($files+1) Then ExitLoop Sleep(10) WEnd Return SetError(0,0,1) EndFunc ;==>_Zip_AddFolder ;=============================================================================== ; ; Function Name: _Zip_AddFolderContents() ; Description: Add a folder to a ZIP Archieve. ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; $hFolder - Complete path to the folder that will be added (possibly including "\" at the end) ; $flag = 1 ; - 1 no progress box ; - 0 progress box ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1~3 ; @error = 1 no Zip file ; @error = 2 no dll ; @error = 3 dll isn't registered ; Author(s): torels_ ; Notes: The return values will be given once the compressing process is ultimated... it takes some time with big files ; ;=============================================================================== Func _Zip_AddFolderContents($hZipFile, $hFolder, $flag = 1) Local $DLLChk = _Zip_DllChk() If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0);no dll If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file If StringRight($hFolder, 1) <> "\" Then $hFolder &= "\" $files = _Zip_Count($hZipFile) $oApp = ObjCreate("Shell.Application") $oFolder = $oApp.NameSpace($hFolder) $oCopy = $oApp.NameSpace($hZipFile).CopyHere($oFolder.Items) $oFC = $oApp.NameSpace($hFolder).items.count While 1 If $flag = 1 then _Hide() If _Zip_Count($hZipFile) = ($files+$oFC) Then ExitLoop Sleep(10) WEnd Return SetError(0,0,1) EndFunc ;==>_Zip_AddFolderContents ;=============================================================================== ; ; Function Name: _Zip_Delete() ; Description: Delete a file from a ZIP Archive. ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; $hFolder - Complete path to the folder that will be added (possibly including "\" at the end) ; $flag = 1 ; - 1 no progress box ; - 0 progress box ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1~3 ; @error = 1 no Zip file ; @error = 2 no dll ; @error = 3 dll isn't registered ; Author(s): torels_ ; Notes: none ; ;=============================================================================== Func _Zip_Delete($hZipFile, $hFilename, $flag = 1) Local $DLLChk = _Zip_DllChk() If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0);no dll If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file $list = _Zip_List($hZipFile) $dir = @TempDir & "\tmp" & Floor(Random(0,100)) For $i = 1 to $list[0] If $list[$i] <> $hFilename Then _Zip_Unzip($hZipFile,$list[$i],$dir, $flag) Next FileDelete($hZipFile) _Zip_Create($hZipFile) _Zip_AddFolderContents($hZipFile, $dir, $flag) DirRemove($dir) EndFunc ;=============================================================================== ; ; Function Name: _Zip_UnzipAll() ; Description: Extract all files contained in a ZIP Archieve. ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; $hDestPath - Complete path to where the files will be extracted ; $flag = 1 ; - 1 no progress box ; - 0 progress box ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1~3 ; @error = 1 no Zip file ; @error = 2 no dll ; @error = 3 dll isn't registered ; Author(s): torels_ ; Notes: The return values will be given once the extracting process is ultimated... it takes some time with big files ; ;=============================================================================== Func _Zip_UnzipAll($hZipFile, $hDestPath, $flag = 1) Local $DLLChk = _Zip_DllChk() If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0);no dll If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path If Not FileExists($hZipFile) Then Return SetError(2, 0, 0) ;no zip file If Not FileExists($hDestPath) Then DirCreate($hDestPath) Local $aArray[1] $oApp = ObjCreate("Shell.Application") $oApp.Namespace($hDestPath).CopyHere($oApp.Namespace($hZipFile).Items) For $item In $oApp.Namespace($hZipFile).Items _ArrayAdd($aArray, $item) Next While 1 If $flag = 1 then _Hide() If FileExists($hDestPath & "\" & $aArray[UBound($aArray) - 1]) Then Return SetError(0, 0, 1) ExitLoop EndIf Sleep(500) WEnd EndFunc ;==>_Zip_UnzipAll ;=============================================================================== ; ; Function Name: _Zip_Unzip() ; Description: Extract a single file contained in a ZIP Archieve. ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; $hFilename - Name of the element in the zip archive ex. "hello_world.txt" ; $hDestPath - Complete path to where the files will be extracted ; $flag = 1 ; - 1 no progress box ; - 0 progress box ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1~3 ; @error = 1 no Zip file ; @error = 2 no dll ; @error = 3 dll isn't registered ; Author(s): torels_ ; Notes: The return values will be given once the extracting process is ultimated... it takes some time with big files ; ;=============================================================================== Func _Zip_Unzip($hZipFile, $hFilename, $hDestPath, $flag = 1) Local $DLLChk = _Zip_DllChk() If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0) ;no dll If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file If Not FileExists($hDestPath) Then DirCreate($hDestPath) $oApp = ObjCreate("Shell.Application") $hFolderitem = $oApp.NameSpace($hZipFile).Parsename($hFilename) $oApp.NameSpace($hDestPath).Copyhere($hFolderitem) While 1 If $flag = 1 then _Hide() If FileExists($hDestPath & "\" & $hFilename) Then return SetError(0, 0, 1) ExitLoop EndIf Sleep(500) WEnd EndFunc ;==>_Zip_Unzip ;=============================================================================== ; ; Function Name: _Zip_Count() ; Description: Count files contained in a ZIP Archieve. ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1~3 ; @error = 1 no Zip file ; @error = 2 no dll ; @error = 3 dll isn't registered ; Author(s): torels_ ; ;=============================================================================== Func _Zip_Count($hZipFile) Local $DLLChk = _Zip_DllChk() If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0) ;no dll If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file $items = _Zip_List($hZipFile) Return UBound($items) - 1 EndFunc ;==>_Zip_Count ;=============================================================================== ; ; Function Name: _Zip_CountAll() ; Description: Count All files contained in a ZIP Archive (including Sub Directories) ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1~3 ; @error = 1 no Zip file ; @error = 2 no dll ; @error = 3 dll isn't registered ; Author(s): torels_, Smashly ; ;=============================================================================== Func _Zip_CountAll($hZipFile) Local $DLLChk = _Zip_DllChk() If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0) ;no dll If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file $oApp = ObjCreate("Shell.Application") $oDir = $oApp.NameSpace(StringLeft($hZipFile, StringInStr($hZipFile, "\", 0, -1))) $sZipInf = $oDir.GetDetailsOf($oDir.ParseName(StringTrimLeft($hZipFile, StringInStr($hZipFile, "\", 0, -1))), -1) Return StringRight($sZipInf, StringLen($sZipInf) - StringInStr($sZipInf, ": ") - 1) EndFunc ;=============================================================================== ; ; Function Name: _Zip_List() ; Description: Returns an Array containing of all the files contained in a ZIP Archieve. ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1~3 ; @error = 1 no Zip file ; @error = 2 no dll ; @error = 3 dll isn't registered ; Author(s): torels_ ; ;=============================================================================== Func _Zip_List($hZipFile) local $aArray[1] Local $DLLChk = _Zip_DllChk() If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0) ;no dll If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file $oApp = ObjCreate("Shell.Application") $hList = $oApp.Namespace($hZipFile).Items For $item in $hList _ArrayAdd($aArray,$item.name) Next $aArray[0] = UBound($aArray) - 1 Return $aArray EndFunc ;==>_Zip_List ;=============================================================================== ; ; Function Name: _Zip_Search() ; Description: Search files in a ZIP Archive. ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; $sSearchString - name of the file to be searched ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1 (no file found) ; Author(s): torels_ ; Notes: none ; ;=============================================================================== Func _Zip_Search($hZipFile, $sSearchString) local $aArray Local $DLLChk = _Zip_DllChk() If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0) ;no dll If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file $list = _Zip_List($hZipFile) for $i = 0 to UBound($list) - 1 if StringInStr($list[$i],$sSearchstring) > 0 Then _ArrayAdd($aArray, $list[$i]) EndIf Next if UBound($aArray) - 1 = 0 Then Return SetError(1,0,0) Else Return $aArray EndIf EndFunc ;==> _Zip_Search ;=============================================================================== ; ; Function Name: _Zip_SearchInFile() ; Description: Search files in a ZIP Archive's File. ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; $sSearchString - name of the file to be searched ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1 (no file found) ; Author(s): torels_ ; Notes: none ; ;=============================================================================== Func _Zip_SearchInFile($hZipFile, $sSearchString) local $aArray $list = _Zip_List($hZipFile) for $i = 1 to UBound($list) - 1 _Zip_Unzip($hZipFile, $list[$i], @TempDir & "\tmp_zip.file") $read = FileRead(@TempDir & "\tmp_zip.file") if StringInStr($read,$sSearchstring) > 0 Then _ArrayAdd($aArray, $list[$i]) EndIf Next if UBound($aArray) - 1 = 0 Then Return SetError(1,0,1) Else Return $aArray EndIf EndFunc ;==> _Zip_Search ;=============================================================================== ; ; Function Name: _Zip_VirtualZipCreate() ; Description: Create a Virtual Zip. ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; $sPath - Path to where create the Virtual Zip ; Requirement(s): none. ; Return Value(s): On Success - List of Created Files ; On Failure - sets @error 1~3 ; @error = 1 no Zip file ; @error = 2 no dll ; @error = 3 dll isn't registered ; Author(s): torels_ ; Notes: none ; ;=============================================================================== Func _Zip_VirtualZipCreate($hZipFile, $sPath) $List = _Zip_List($hZipFile) If @error Then Return SetError(@error,0,0) If Not FileExists($sPath) Then DirCreate($sPath) If StringRight($sPath, 1) = "\" Then $sPath = StringLeft($sPath, StringLen($sPath) -1) For $i = 1 to $List[0] If Not @Compiled Then $Cmd = @AutoItExe $params = '"' & @ScriptFullPath & '" ' & '"' & $hZipFile & "," & $List[$i] & '"' Else $Cmd = @ScriptFullPath $Params = '"' & $hZipFile & "," & $List[$i] & '"' EndIf FileCreateShortcut($Cmd, $sPath & "\" & $List[$i], -1,$Params, "Virtual Zipped File", _GetIcon($List[$i], 0), "", _GetIcon($List[$i], 1)) Next $List = _ArrayInsert($List, 1, $sPath) Return $List EndFunc ;=============================================================================== ; ; Function Name: _Zip_VirtualZipOpen() ; Description: Open A File in a Virtual Zip, Internal Function. ; Parameter(s): none. ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1~3 ; @error = 1 no Zip file ; @error = 2 no dll ; @error = 3 dll isn't registered ; Author(s): torels_ ; Notes: none ; ;=============================================================================== Func _Zip_VirtualZipOpen() $ZipSplit = StringSplit($CMDLine[1], ",") $ZipName = $ZipSplit[1] $ZipFile = $ZipSplit[2] _Zip_Unzip($ZipName, $ZipFile, @TempDir & "\", 4+16) ;no progress + yes to all If @error Then Return SetError(@error,0,0) ShellExecute(@TempDir & "\" & $ZipFile) EndFunc ;=============================================================================== ; ; Function Name: _Zip_VirtualZipOpen() ; Description: Delete a Virtual Zip. ; Parameter(s): none. ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - none. ; Author(s): torels_ ; Notes: none ; ;=============================================================================== Func _Zip_VirtualZipDelete($aVirtualZipHandle) For $i = 2 to UBound($aVirtualZipHandle)-1 If FileExists($aVirtualZipHandle[1] & "\" & $aVirtualZipHandle[$i]) Then FileDelete($aVirtualZipHandle[1] & "\" & $aVirtualZipHandle[$i]) Next Return 0 EndFunc ;=============================================================================== ; ; Function Name: _Zip_DllChk() ; Description: Internal error handler. ; Parameter(s): none. ; Requirement(s): none. ; Return Value(s): Failure - @extended = 1 ; Author(s): smashley ; ;=============================================================================== Func _Zip_DllChk() If Not FileExists(@SystemDir & "\zipfldr.dll") Then Return 2 If Not RegRead("HKEY_CLASSES_ROOT\CLSID\{E88DCCE0-B7B3-11d1-A9F0-00AA0060FA31}", "") Then Return 3 Return 0 EndFunc ;==>_Zip_DllChk ;=============================================================================== ; ; Function Name: _GetIcon() ; Description: Internal Function. ; Parameter(s): $file - File form which to retrieve the icon ; $ReturnType - IconFile or IconID ; Requirement(s): none. ; Return Value(s): Icon Path/ID ; Author(s): torels_ ; ;=============================================================================== Func _GetIcon($file, $ReturnType = 0) $FileType = StringSplit($file, ".") $FileType = $FileType[UBound($FileType)-1] $FileParam = RegRead("HKEY_CLASSES_ROOT\." & $FileType, "") $DefaultIcon = RegRead("HKEY_CLASSES_ROOT\" & $FileParam & "\DefaultIcon", "") If Not @error Then $IconSplit = StringSplit($DefaultIcon, ",") ReDim $IconSplit[3] $Iconfile = $IconSplit[1] $IconID = $IconSplit[2] Else $Iconfile = @SystemDir & "\shell32.dll" $IconID = -219 EndIf If $ReturnType = 0 Then Return $Iconfile Else Return $IconID EndIf EndFunc ;=============================================================================== ; ; Function Name: _IsFullPath() ; Description: Internal Function. ; Parameter(s): $path - a zip path ; Requirement(s): none. ; Return Value(s): success - True. ; failure - False. ; Author(s): torels_ ; ;=============================================================================== Func _IsFullPath($path) if StringInStr($path,":\") then Return True Else Return False EndIf Endfunc ;=============================================================================== ; ; Function Name: _Hide() ; Description: Internal Function. ; Parameter(s): none ; Requirement(s): none. ; Return Value(s): none. ; Author(s): torels_ ; ;=============================================================================== Func _Hide() If ControlGetHandle("[CLASS:#32770]", "", "[CLASS:SysAnimate32; INSTANCE:1]") <> "" And WinGetState("[CLASS:#32770]") <> @SW_HIDE Then ;The Window Exists $hWnd = WinGetHandle("[CLASS:#32770]") WinSetState($hWnd, "", @SW_HIDE) EndIf EndFunc Notes: What happens is it deletes everything in the media folder that it added when i close the program, and it also breaks a part of the shortcuts too.. I cant figure it out in the slightest bit I added the line : Global $oApp, $hWnd in the Zip.au3 file because my script said these variables were undeclared. Can someone please tell me whats wrong! my script works perfect until i close it, then it deletes all its work Link to comment Share on other sites More sharing options...
taietel Posted September 29, 2010 Share Posted September 29, 2010 I did not tested it, but I think your problem lies in the UnzipMusic($Music) function... First, try to comment line 103 of your script. Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
Raffle Posted September 29, 2010 Author Share Posted September 29, 2010 I did not tested it, but I think your problem lies in the UnzipMusic($Music) function...First, try to comment line 103 of your script.I think your right, I recently noticed the weirdest thing, When i hit the x on the top right to quit, the statusbar on the bottom says Unpacking. Somehow its running UnzipMusic when i close the program, but HOW? Link to comment Share on other sites More sharing options...
wakillon Posted September 29, 2010 Share Posted September 29, 2010 (edited) What happens is it deletes everything in the media folderI think the problem is in this part :local $MusicDirDelete = $MusicDir & "\media"; FileDelete($MusicDirDelete); FileDelete($MusicDirDelete)If $Music = $MusicDirTypex Then $Status = $Music & " Is Already Installed" GUICtrlSetData($StatusLabel, $Status) Else If $Music = "MusicNone" Then $Status = "Deleting Bad media Folder" GUICtrlSetData($StatusLabel, $Status) FileDelete($MusicDirDelete) $Status = "Installing " & $Music GUICtrlSetData($StatusLabel, $Status) _Zip_UnzipAll($DaiMusicDir & "media.zip", $DaiDirectory) $Status = $Music & " Is Installed" GUICtrlSetData($StatusLabel, $Status) Else $Status = "Deleting Bad media Folder" GUICtrlSetData($StatusLabel, $Status) FileDelete($MusicDirDelete) $Status = "Unpacking " & $Music GUICtrlSetData($StatusLabel, $Status) If $Music = "AllMusic" Then $MusicDir = $DaiDirectory & "\media" EndIf _Zip_UnzipAll($DaiMusicDir & $Music & ".zip", $MusicDir) FileCopy($DaiMusicDir & "media\orchestral.ogg",$DaiDirectory & "\media\orchestral.ogg") $Status = $Music & " Successfully Installed" GUICtrlSetData($StatusLabel, $Status) EndIf EndIfA condition may be wrong, add some consolewrite to get value and find where it's bad... Edited September 29, 2010 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Raffle Posted September 29, 2010 Author Share Posted September 29, 2010 I think there is another root to the problem tho, That may fix it, but i want to know why its running the UnzipMusic function when i close the program. Those FileDelete functions are important for the program to work properly. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted September 29, 2010 Share Posted September 29, 2010 Why don't you start by fixing this: Case $msg = $MusicNone UnzipMusic("MusicNone") Case $msg = $GUI_EVENT_CLOSE EndSelect and see if it gets any better. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Raffle Posted September 29, 2010 Author Share Posted September 29, 2010 Why don't you start by fixing this: Case $msg = $MusicNone UnzipMusic("MusicNone") Case $msg = $GUI_EVENT_CLOSE EndSelect and see if it gets any better. I dont see a problem there? commenting out the UnzipMusic("MusicNone") Line doesnt get rid of the problem, it still deletes my stuff after i close the program. Thats the problem, for some reason it reruns the UnzipMusic function after i close the program >< Link to comment Share on other sites More sharing options...
kaotkbliss Posted September 29, 2010 Share Posted September 29, 2010 I think the problem is this Case $msg = $GUI_EVENT_CLOSE EndSelect What is it you want the script to do when $GUI_EVENT_CLOSE? My guess is exit the script... Case $msg = $GUI_EVENT_CLOSE Exit(1) EndSelect 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Raffle Posted September 29, 2010 Author Share Posted September 29, 2010 I think the problem is thisCase $msg = $GUI_EVENT_CLOSEEndSelectWhat is it you want the script to do when $GUI_EVENT_CLOSE?My guess is exit the script...Case $msg = $GUI_EVENT_CLOSEExit(1)EndSelectThat made my script work flawlessly thank you so much! Link to comment Share on other sites More sharing options...
trancexx Posted September 29, 2010 Share Posted September 29, 2010 Why in the world would you use that idiotic torels_'s zip UDF when there is a normal one available made by wraithdu? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Raffle Posted September 29, 2010 Author Share Posted September 29, 2010 Why in the world would you use that idiotic torels_'s zip UDF when there is a normal one available made by wraithdu?Because i didnt know another existed? Im new to autoit obviously, look at my code 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