Voila la version final du Zip pour autoit. Elle marche à 100%.
Le fichier à lancer est : Autoit_zip.au3 et l'udf est de rasim.
Les archives crées se retrouveront sur votre bureau, avec l'heure et la date de sa création.
► Afficher le textele code
Code : Tout sélectionner
#include <GuiConstants.au3>
#include <Zip.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <Zip32.au3>
#include <GuiConstantsEx.au3>
GuiCreate("Autoit Zipper", 350, 260)
If not FileExists("ressources/temp.ini") Then
Filewrite ("ressources/temp.ini", "[File]" & @CRLF)
Filewrite ("ressources/temp.ini", "[Folder]")
Endif
$Input_1 = GUICtrlCreateInput("Zipper Made By Jbnh | UDF By par rasim", 55, 10, 220, 20)
$Button_1 = GUICtrlCreatePic("ressources/file.jpg", 280, 10, 15, 16)
$Button_2 = GUICtrlCreatePic("ressources/folder.jpg",305, 10, 16, 15)
;-----------------------------------------------------------------------------------------------------------
$Input_2 = GUICtrlCreateEdit("", 25, 50, 300, 140)
;-----------------------------------------------------------------------------------------------------------
$Input_3 = GUICtrlCreateLabel("0", 110, 200)
GUICtrlCreateLabel("Fichiers et ", 120, 200)
$Input_4 = GUICtrlCreateLabel("0", 175, 200)
GUICtrlCreateLabel("Dossiers", 185, 200)
$Button_3 = GUICtrlCreateButton("Zip now !", 140, 230, 70, 20)
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Button_1
$Opened_File = FileOpenDialog("Add File", "", "All Files (*.*)",12)
If GUICtrlRead($Input_2) = "" Then
$Tmp = $Opened_File
Else
$Tmp = GUICtrlRead($Input_2) & @CRLF & $Opened_File
Endif
If not $Opened_File = "" Then
GUICtrlSetData($Input_2, "")
GUICtrlSetData($Input_2, $Tmp)
$addfile = GUICtrlRead($Input_3) + 1
GUICtrlSetData($Input_3, $addfile)
IniWrite(@scriptdir & "/ressources/temp.ini", "File", "key"&$addfile, $Opened_File)
Endif
Case $msg = $Button_2
$Opened_File2 = FileSelectFolder("Choose a folder.", "")
If GUICtrlRead($Input_2) = "" Then
$Tmp2 = $Opened_File2
Else
$Tmp2 = GUICtrlRead($Input_2) & @CRLF & $Opened_File2
Endif
If not $Opened_File2 = "" Then
GUICtrlSetData($Input_2, "")
GUICtrlSetData($Input_2, $Tmp2)
$addfolder = GUICtrlRead($Input_4) + 1
GUICtrlSetData($Input_4, $addfolder)
IniWrite(@scriptdir & "/ressources/temp.ini", "Folder", "key"&$addfolder, $Opened_File2)
Endif
Case $msg = $Button_3
If GUICtrlRead($Input_2) = "" Then
MsgBox(64, "Error", "You didnt choose any file!")
Exit
Endif
Global $CurZipSize = 0
$hGUI = GUICreate("ZIP", 300, 160)
$edit = GUICtrlCreateEdit("", 10, 10, 280, 100, BitOR($WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY))
$progress = GUICtrlCreateProgress(10, 125, 280, 20)
GUISetState()
$ZipFile = @DesktopDir&"\Zip-"&@MDAY&"."&@MON&" at "&@HOUR&"."&@MIN&".zip"
$FileToZip = GUICtrlRead($Input_2)
$UnCompSize = DirGetSize($FileToZip)
_Zip_Init("_ZIPPrint", "_ZIPPassword", "_ZIPComment", "_ZIPProgress")
If @error Then
MsgBox(16, "Error", "Zip32.dll did not initialize")
Exit
EndIf
_Zip_SetOptions()
If @error Then
MsgBox(16, "Error", "Options sets error")
Exit
EndIf
$aFiles = StringSplit($FileToZip, @CRLF)
If UBound($aFiles) > 2 Then
For $i = 1 To $aFiles[0]
_ZIP_Archive($ZipFile, $aFiles[$i])
Next
Else
_ZIP_Archive($ZipFile, $aFiles[1])
EndIf
If @error Then
MsgBox(16, "Error", "Archive creating error")
Else
MsgBox(64, "Success", "Archive creating successful")
EndIf
GUICtrlSetData($progress, 0)
GUICtrlSetData($edit, "")
$CurZipSize = 0
EndSelect
Wend
;==========================# ZIP FUNCTIONS #======================================
Func _ZIPPrint($sFile, $sPos)
ConsoleWrite("!> _ZIPPrint: " & $sFile & @LF)
EndFunc
Func _ZIPPassword($sPWD, $sX, $sS2, $sName)
Local $iPass = InputBox("Archive encrypting set", "Enter the password", "", "", 300, 120)
If $iPass = "" Then Return 1
Local $PassBuff = DllStructCreate("char[256]", $sPWD)
DllStructSetData($PassBuff, 1, $iPass)
EndFunc
Func _ZIPComment($sComment)
Local $iComment = InputBox("Archive comment set", "Enter the comment", "", "", 300, 120)
If $iComment = "" Then Return 1
Local $CommentBuff = DllStructCreate("char[256]", $sComment)
DllStructSetData($CommentBuff, 1, $iComment)
EndFunc
Func _ZIPProgress($sName, $sSize)
$CurZipSize += Number($sSize)
Local $iPercent = Round(($CurZipSize / $UnCompSize * 100))
GUICtrlSetData($progress, $iPercent)
GUICtrlSetData($edit, $sName & @CRLF, 1)
ConsoleWrite("!> Name: " & $sName & @LF)
EndFunc