Jump to content

7-Zip Compressor


AlMax3000
 Share

Recommended Posts

hi! I wanted to know if this program I did is fine, it works fine but I would like some opinions

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

#Region ### START Koda GUI section ### Form=
$FormName = "7-Zip Compressore"
$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, "Folder Selection")
$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, "File saving")
$Pass = GUICtrlCreateInput("", 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, "Protegge il file con 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)
$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, '0')
$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)
$Label = GUICtrlCreateLabel("", 480, 260, 67, 12, -1, $WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 6, 400, 0, "arial")
GUICtrlSetColor(-1, 0x000080)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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


$SliderCorrente = 5
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
            

        Case $BtnBrowse
        Local $sSelectFolder = FileSelectFolder("Select Folder", "")        
        If @error Then continueloop
        GUICtrlSetData($Inp, $sSelectFolder)
        Local $iSize = DirGetSize($sSelectFolder)   
        GUICtrlSetData($LabelSize,"Dim: " & _GetDisplaySize($iSize))
        
        Case $BtnBrowseFile
        Local $sFileOpenDialog = FileOpenDialog("Select files", @DesktopDir , "All (*.*)", $FD_FILEMUSTEXIST)
        If @error Then continueloop
        GUICtrlSetData($Inp, $sFileOpenDialog)
        Local $iSize =  FileGetSize($sFileOpenDialog)   
        GUICtrlSetData($LabelSize,"Dimensione: " & _GetDisplaySize($iSize))
        
        Case $BtnSave
        Local $sFileSaveDialog = FileSaveDialog("Save files with name ", @DesktopDir , "Files type (*.7z)|Files type (*.zip)", $FD_PATHMUSTEXIST)
        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()    
    _FileWrite()

    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
    GUICtrlSetData($Label,"7zG.exe Ver: " &$sFileVersion)
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 "' & GUICtrlRead($Out) & '" "' & GUICtrlRead($Inp) & '"')
else
$cmd = Run($7zDir & ' a -mx "' & GUICtrlRead($Out) & '" "' & '"-p"' & GUICtrlRead($pass) & '" "' & GUICtrlRead($Inp) & '\*"')
endif
EndFunc
Quote

 

 

Edited by AlMax3000
Link to comment
Share on other sites

Quote

I wanted to know if this program I did is fine, it works fine but I would like some opinions 

_Seven_Zip()
            _FileWrite()

-> error: _FileWrite(): undefined function

-> \Bin\icons\ ==> no icons provided

-> avoid Local declarations inside While-Loop -> e.g. Local $sSelectFolder

Edited by Musashi

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

14 minutes ago, AlMax3000 said:

icon working bro >  to: Bin\icons 😄

Not with me, see :

$BtnBrowse = GUICtrlCreateButton("", 480, 6, 25, 25, $BS_ICON)
GUICtrlSetImage(-1, @ScriptDir & "\Bin\icons\i1.ico", -1)
ConsoleWrite(" GUICtrlSetImage : @error = " & @error & @CRLF)

==>  GUICtrlSetImage : @error = 0 (Return Value  0 = Failure)

You probably have a folder:  @ScriptDir & "\Bin\icons\..."  with the icons.

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

 is possible can insert the folder to be compressed as a name instead of the optional name:

 

sorry I do not understand English well .. I saw a closed thread for game graphics (what game graphics means)

 

I did a scan and found a spyware by work that I took from a script downloaded from the net, I deleted everything with adwclear, I don't intend to break the rules absolutely, I just ask for small and simple aids, a window with the image of I do not remember now, maybe it is that but I repeat I have no faults

 

 

 

 

 

Screenshot_1.png

Edited by AlMax3000
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...