Jump to content

7zip Gui Compressor -


Giggo
 Share

Go to solution Solved by ad777,

Recommended Posts

4 minutes ago, Giggo said:

hi! 
I get an error when I save the file with password with folder everything is ok
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <SendMessage.au3>
#include <Constants.au3>

$FormName = "7-Zip Press"
$Form1 = GUICreate($FormName, 550, 275, -1, -1)
;-GUISetBkColor(0xFFFFFF)
GUISetIcon("shell32.dll", 160)
$Inp = GUICtrlCreateInput("", 8, 8, 465, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
GUICtrlSetFont(-1, 9, 400, 0, "Courier New")
GUICtrlSetBkColor($Inp,0xFFFFFF)
GUICtrlSetColor(-1, 0x001E1E1E)
GUICtrlSetTip(-1, "Input")
$Out = GUICtrlCreateInput("", 8, 40, 465, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
GUICtrlSetFont(-1, 9, 400, 0, "Courier New")
GUICtrlSetBkColor($Out,0xFFFFFF)
GUICtrlSetColor(-1, 0x001E1E1E)
GUICtrlSetTip(-1, "Output")
$Pass = GUICtrlCreateInput("password", 40, 72, 433, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetFont(-1, 9, 400, 0, "Courier New")
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetTip(-1, "Protect the file with password")
$BtnBrowse = GUICtrlCreateButton("", 480, 6, 25, 25, $BS_ICON)
GUICtrlSetImage(-1, @ScriptDir & "\Bin\icons\i1.ico", -1)
GUICtrlSetTip(-1, "select folder")
$BtnBrowseFile = GUICtrlCreateButton("", 515, 6, 25, 25, $BS_ICON)
GUICtrlSetImage(-1, @ScriptDir & "\Bin\icons\i2.ico", -1)
GUICtrlSetTip(-1, "select file")
$BtnSave = GUICtrlCreateButton("", 480, 38, 25, 25, $BS_ICON)
GUICtrlSetImage(-1, @ScriptDir & "\Bin\icons\i3.ico", -1)
GUICtrlSetTip(-1, "save file")
$BtnCompress = GUICtrlCreateButton("", 480, 70, 25, 25, $BS_ICON)
GUICtrlSetImage(-1, @ScriptDir & "\Bin\icons\i4.ico", -1)
GUICtrlSetTip(-1, "Compress")
$BtnCancPass = GUICtrlCreateButton("", 8, 70, 25, 25, $BS_ICON)
GUICtrlSetImage(-1, @ScriptDir & "\Bin\icons\i5.ico", -1)
GUICtrlSetTip(-1, "Cancel password")
$Group1 = GUICtrlCreateGroup("Sets level of compression", 8, 120, 257, 145)
GUICtrlSetFont(-1, 9, 400, 0, "Courier New")
$Slider = GUICtrlCreateSlider(20, 146, 230, 25)
GUICtrlSetLimit(-1, 5)
$CompLabel = GUICtrlCreateLabel("Ultra", 31, 182, 116, 15)
GUICtrlSetFont(-1, 9, 400, 0, "Courier New")
GUICtrlSetColor(-1, 0x000080)
GUICtrlSetData($Slider, '3')
$LabelSize = GUICtrlCreateLabel("", 31, 226, 200, 29)
GUICtrlSetTip(-1, "Size of the selected directory, folder or file")
GUICtrlSetFont(-1, 9, 400, 0, "Courier New")
GUICtrlSetColor(-1, 0x000080)
GUICtrlSetColor(-1, 0x000080)
GUISetState(@SW_SHOW)


;~~~~~~$sFileName = @ScriptDir &"\pass.txt"
;~~~~~~$hFilehandle = FileOpen($sFileName, $FO_OVERWRITE)
Local $7zDir = '"' & @ScriptDir & '\Bin\7zG.exe"'

$SliderCorrente = 5

    
While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        
        Case $BtnBrowse
        $sSelectFolder = FileSelectFolder("Select Folder", "")      
        If @error Then continueloop
        GUICtrlSetData($Inp, $sSelectFolder)
        $iSize = DirGetSize($sSelectFolder) 
        GUICtrlSetData($LabelSize,"Dim: " & _GetDisplaySize($iSize))
        
        Case $BtnBrowseFile
        $sFileOpenDialog = FileOpenDialog("Select files", @DesktopDir , "All (*.*)", $FD_FILEMUSTEXIST)
        If @error Then continueloop
        GUICtrlSetData($Inp, $sFileOpenDialog)
        $iSize =  FileGetSize($sFileOpenDialog) 
        GUICtrlSetData($LabelSize,"Dimensione: " & _GetDisplaySize($iSize))
        
        Case $BtnSave
        $sFileSaveDialog = FileSaveDialog("Save the file with name", @DesktopDir, "Format (*.7z)|Format (*.zip)", 2, "_Zipped")
        GUICtrlSetData($Out, $sFileSaveDialog)
        If @error Then continueloop 
        
       Case $BtnCompress 
       If GUICtrlRead($Inp) = "" Then
       MsgBox(48, $FormName, "The boxes must not be empty!")
       ContinueLoop
       EndIf
       If GUICtrlRead($Out) = "" Then
       MsgBox(48, $FormName, "The boxes must not be empty!")
       ContinueLoop
       EndIf 
    _Seven_Zip()    

    Case $BtnCancPass
    GUICtrlSetData($pass,"")
    
    EndSwitch
        If GUICtrlRead($Slider) <> $SliderCorrente Then
        $SliderCorrente = GUICtrlRead($Slider)
        Select
            Case $SliderCorrente = 5
                GUICtrlSetData($CompLabel, "Ultra")
                $livello = 9
            Case $SliderCorrente = 4
                GUICtrlSetData($CompLabel, "Maximum")
                $livello = 7
            Case $SliderCorrente = 3
                GUICtrlSetData($CompLabel, "Normal")
                $livello = 5
            Case $SliderCorrente = 2
                GUICtrlSetData($CompLabel, "Fast")
                $livello = 3
            Case $SliderCorrente = 1
                GUICtrlSetData($CompLabel, "Fastest")
                $livello = 1
            Case $SliderCorrente = 0
                GUICtrlSetData($CompLabel, "Copy")
                $livello = 0
        EndSelect
    EndIf   
WEnd


Func _GetDisplaySize($iSize, $iPlaces = 2)
    Local $aBytes[5] = [' Bytes', ' KB', ' MB', ' GB', ' TB']
    For $i = 4 To 1 Step -1
        If $iSize >= 1024 ^ $i Then
            Return Round($iSize / 1024 ^ $i, $iPlaces) & $aBytes[$i]
        EndIf
    Next
    Return $iSize & ' Bytes'
EndFunc



Func _Seven_Zip()   
If GUICtrlRead($pass) = "" Then
$cmd = Run($7zDir & ' a -mx="' & $livello & '" "' & GUICtrlRead($Out) & '" "' & GUICtrlRead($Inp) & '"')
else
$cmd = Run($7zDir & ' a -mx="' & $livello & '" "' & GUICtrlRead($Out) & '" "' & '"-p"' & GUICtrlRead($pass) & '" "' & GUICtrlRead($Inp) & '\*"')
endif
EndFunc

 

Link to comment
Share on other sites

  • Solution

@Giggo

just replace this:

$cmd = Run($7zDir & ' a -mx="' & $livello & '" "' & GUICtrlRead($Out) & '" "' & '"-p"' & GUICtrlRead($pass) & '" "' & GUICtrlRead($Inp) & '\*"')

with:

$cmd = Run($7zDir & ' a -mx="' & $livello & '" "' & GUICtrlRead($Out) & '" "' & '"-p"' & GUICtrlRead($pass) & '" "' & GUICtrlRead($Inp) & '*"')

the script will be:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <SendMessage.au3>
#include <Constants.au3>

$FormName = "7-Zip Press"
$Form1 = GUICreate($FormName, 550, 275, -1, -1)
;-GUISetBkColor(0xFFFFFF)
GUISetIcon("shell32.dll", 160)
$Inp = GUICtrlCreateInput("", 8, 8, 465, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
GUICtrlSetFont(-1, 9, 400, 0, "Courier New")
GUICtrlSetBkColor($Inp,0xFFFFFF)
GUICtrlSetColor(-1, 0x001E1E1E)
GUICtrlSetTip(-1, "Input")
$Out = GUICtrlCreateInput("", 8, 40, 465, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
GUICtrlSetFont(-1, 9, 400, 0, "Courier New")
GUICtrlSetBkColor($Out,0xFFFFFF)
GUICtrlSetColor(-1, 0x001E1E1E)
GUICtrlSetTip(-1, "Output")
$Pass = GUICtrlCreateInput("password", 40, 72, 433, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetFont(-1, 9, 400, 0, "Courier New")
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetTip(-1, "Protect the file with password")
$BtnBrowse = GUICtrlCreateButton("", 480, 6, 25, 25, $BS_ICON)
GUICtrlSetImage(-1, @ScriptDir & "\Bin\icons\i1.ico", -1)
GUICtrlSetTip(-1, "select folder")
$BtnBrowseFile = GUICtrlCreateButton("", 515, 6, 25, 25, $BS_ICON)
GUICtrlSetImage(-1, @ScriptDir & "\Bin\icons\i2.ico", -1)
GUICtrlSetTip(-1, "select file")
$BtnSave = GUICtrlCreateButton("", 480, 38, 25, 25, $BS_ICON)
GUICtrlSetImage(-1, @ScriptDir & "\Bin\icons\i3.ico", -1)
GUICtrlSetTip(-1, "save file")
$BtnCompress = GUICtrlCreateButton("", 480, 70, 25, 25, $BS_ICON)
GUICtrlSetImage(-1, @ScriptDir & "\Bin\icons\i4.ico", -1)
GUICtrlSetTip(-1, "Compress")
$BtnCancPass = GUICtrlCreateButton("", 8, 70, 25, 25, $BS_ICON)
GUICtrlSetImage(-1, @ScriptDir & "\Bin\icons\i5.ico", -1)
GUICtrlSetTip(-1, "Cancel password")
$Group1 = GUICtrlCreateGroup("Sets level of compression", 8, 120, 257, 145)
GUICtrlSetFont(-1, 9, 400, 0, "Courier New")
$Slider = GUICtrlCreateSlider(20, 146, 230, 25)
GUICtrlSetLimit(-1, 5)
$CompLabel = GUICtrlCreateLabel("Ultra", 31, 182, 116, 15)
GUICtrlSetFont(-1, 9, 400, 0, "Courier New")
GUICtrlSetColor(-1, 0x000080)
GUICtrlSetData($Slider, '3')
$LabelSize = GUICtrlCreateLabel("", 31, 226, 200, 29)
GUICtrlSetTip(-1, "Size of the selected directory, folder or file")
GUICtrlSetFont(-1, 9, 400, 0, "Courier New")
GUICtrlSetColor(-1, 0x000080)
GUICtrlSetColor(-1, 0x000080)
GUISetState(@SW_SHOW)


;~~~~~~$sFileName = @ScriptDir &"\pass.txt"
;~~~~~~$hFilehandle = FileOpen($sFileName, $FO_OVERWRITE)
Local $7zDir = '"' & @ScriptDir & '\Bin\7zG.exe"'

$SliderCorrente = 5

    
While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        
        Case $BtnBrowse
        $sSelectFolder = FileSelectFolder("Select Folder", "")      
        If @error Then continueloop
        GUICtrlSetData($Inp, $sSelectFolder)
        $iSize = DirGetSize($sSelectFolder) 
        GUICtrlSetData($LabelSize,"Dim: " & _GetDisplaySize($iSize))
        
        Case $BtnBrowseFile
        $sFileOpenDialog = FileOpenDialog("Select files", @DesktopDir , "All (*.*)", $FD_FILEMUSTEXIST)
        If @error Then continueloop
        GUICtrlSetData($Inp, $sFileOpenDialog)
        $iSize =  FileGetSize($sFileOpenDialog) 
        GUICtrlSetData($LabelSize,"Dimensione: " & _GetDisplaySize($iSize))
        
        Case $BtnSave
        $sFileSaveDialog = FileSaveDialog("Save the file with name", @DesktopDir, "Format (*.7z)|Format (*.zip)", 2, "_Zipped")
        GUICtrlSetData($Out, $sFileSaveDialog)
        If @error Then continueloop 
        
       Case $BtnCompress 
       If GUICtrlRead($Inp) = "" Then
       MsgBox(48, $FormName, "The boxes must not be empty!")
       ContinueLoop
       EndIf
       If GUICtrlRead($Out) = "" Then
       MsgBox(48, $FormName, "The boxes must not be empty!")
       ContinueLoop
       EndIf 
    _Seven_Zip()    

    Case $BtnCancPass
    GUICtrlSetData($pass,"")
    
    EndSwitch
        If GUICtrlRead($Slider) <> $SliderCorrente Then
        $SliderCorrente = GUICtrlRead($Slider)
        Select
            Case $SliderCorrente = 5
                GUICtrlSetData($CompLabel, "Ultra")
                $livello = 9
            Case $SliderCorrente = 4
                GUICtrlSetData($CompLabel, "Maximum")
                $livello = 7
            Case $SliderCorrente = 3
                GUICtrlSetData($CompLabel, "Normal")
                $livello = 5
            Case $SliderCorrente = 2
                GUICtrlSetData($CompLabel, "Fast")
                $livello = 3
            Case $SliderCorrente = 1
                GUICtrlSetData($CompLabel, "Fastest")
                $livello = 1
            Case $SliderCorrente = 0
                GUICtrlSetData($CompLabel, "Copy")
                $livello = 0
        EndSelect
    EndIf   
WEnd


Func _GetDisplaySize($iSize, $iPlaces = 2)
    Local $aBytes[5] = [' Bytes', ' KB', ' MB', ' GB', ' TB']
    For $i = 4 To 1 Step -1
        If $iSize >= 1024 ^ $i Then
            Return Round($iSize / 1024 ^ $i, $iPlaces) & $aBytes[$i]
        EndIf
    Next
    Return $iSize & ' Bytes'
EndFunc



Func _Seven_Zip()   
If GUICtrlRead($pass) = "" Then
$cmd = Run($7zDir & ' a -mx="' & $livello & '" "' & GUICtrlRead($Out) & '" "' & GUICtrlRead($Inp) & '"')
else
$cmd = Run($7zDir & ' a -mx="' & $livello & '" "' & GUICtrlRead($Out) & '" "' & '"-p"' & GUICtrlRead($pass) & '" "' & GUICtrlRead($Inp) & '*"')
endif
EndFunc

 

Edited by ad777

iam ِAutoit programmer.

best thing in life is to use your Brain to

Achieve

everything you want.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...