Jump to content

ArcThemALL (FreeArc compress)


OmarPapi
 Share

Recommended Posts

;Lupo73 Source
#include <GUIListView.au3>
#include <GUIToolTip.au3>

Global Const $GUI_EVENT_CLOSE = -3
Global Const $GUI_EVENT_DROPPED = -13
Global Const $GUI_CHECKED = 1
Global Const $GUI_UNCHECKED = 4
Global Const $GUI_DROPACCEPTED = 8
Global Const $GUI_SHOW = 16
Global Const $GUI_HIDE = 32
Global Const $GUI_ENABLE = 64
Global Const $GUI_DISABLE = 128
Global Const $GUI_FOCUS = 256
Global Const $GUI_RUNDEFMSG = 'GUI_RUNDEFMSG'

Global Const $WS_EX_ACCEPTFILES = 0x00000010
Global Const $WS_EX_TOOLWINDOW = 0x00000080
Global Const $WS_EX_CLIENTEDGE = 0x00000200
Global Const $WM_NOTIFY = 0x004E
Global Const $WM_DROPFILES = 0x233

; #include <ButtonConstants.au3>
Global Const $BS_DEFPUSHBUTTON = 0x0001
Global Const $BS_ICON = 0x0040

Opt('MustDeclareVars', 1)
Opt("TrayIconHide", 1)

Global $wait = 250
Global $version = "ArcThemAll!"
Global $sIni = @ScriptDir & "\config.ini"
Global $upp = "Name                                   |Directory                              |Source |Result  "
Global $zipMod = "Normal compression"
Global $zipList = "Normal compression|Single archive per file|Single archive per folder"
Global $zipModD = "Normal extraction"
Global $zipListD = "Normal extraction|New folder each archive|All in main folder"
Global $gaDropFiles[1]
Global $sData, $temp, $i, $mainf, $item, $attrib, $hListView, $counter, $count = 0

_Main()

Func ConvSize($size)            ; OK
 $size = $size/1024
 If $size < 2 Then
  $size = "1 KB"
 ElseIf $size < 1000 Then
  $size = StringFormat("%.0d", $size) & " KB"
 ElseIf $size < 10000 Then
  $size = StringFormat("%.2f", $size/1024) & " MB"
 ElseIf $size < 100000 Then
  $size = StringFormat("%.1f", $size/1024) & " MB"
 ElseIf $size < 1000000 Then
  $size = StringFormat("%.0d", $size/1024) & " MB"
 ElseIf $size > 999999 Then
  $size = StringFormat("%.2f", $size/1048576) & " GB"
 EndIf
 Return $size
EndFunc


Func ARC_BuildCommand($arcMode)         ; OK
 Local $command, $arcExe, $co, $rest, $pass

 ;Add compressor path
 $arcExe = '"' & @ScriptDir & '\data\FreeArc\arc.exe" '
 
 ;Add compression/decompression variant
 $co = "comp-mode "
 
 ;Add password
 If IniRead($sIni, "Options", "Encrypt", "0") = "1" Then
  $pass = '"-p' & IniRead($sIni, "Options", "Password", "0") & '"  -mem=AES256 '
 Else
  $pass = ' '
 EndIf
 
 If $arcMode = "comp" Then
  $rest = "-mx "
  $command = $arcExe & $co & $rest & $pass
 Else
  $rest = "a "
  $command = $arcExe & $co & $rest
 EndIf
 Return $command
EndFunc


Func SEZ_BuildCommand($arcMode)         ; OK
 Local $command, $arcExe, $co, $rest, $pass, $sfx

 ;Add compressor path
 $arcExe = '"' & @ScriptDir & '\data\FreeArc\arc.exe" '
 
 ;Add compression/decompression variant
 $co = "comp-mode "
 
 ;Add password
 If IniRead($sIni, "Options", "Encrypt", "0") = "1" Then
  $pass = '"-p' & IniRead($sIni, "Options", "Password", "0") & '" -mhe=on '
 Else
  $pass = ''
 EndIf
 
 ;Add self extracting mode
 If IniRead($sIni, "Options", "SelfExtract", "0") = "1" Then
  $sfx = '-sfxfreearc.sfx '
 Else
  $sfx = ''
 EndIf
 
 If $arcMode = "comp" Then
  $rest = "-mx "
  $command = $arcExe & $co & $rest & $pass & $sfx
 EndIf
 Return $command
EndFunc


Func ArcFile($format, $modality, $k, $command, $dir, $file, $name, $textState, $show, $intell, $arcMode, $parent)           ; OK
 Local $j, $todo = 1, $process, $size, $err, $commandT, $password, $ff, $fff = 0

 If Not FileExists($file) Then
  $todo = 2
  Return $todo
 EndIf
 

 If $format = "ARC" Then
  If $arcMode = "comp" Then
   $attrib = FileGetAttrib($file)
   If $modality = "1" Then
    If $parent = 1 Then
     $todo = 1
    Else
     $todo = 0
    EndIf
   ElseIf $modality = "2" Then
    If StringInStr($attrib, "D") Then
     $todo = 0
    Else
     $todo = 1
    EndIf
   Else
    If StringInStr($attrib, "D") Then
     $todo = 1
    Else
     $todo = 0
    EndIf
   EndIf
   If $todo = 1 Then
    ; set the exe format if is in self-extracting mode
    If IniRead($sIni, "Options", "Format", "0") = "ARC" And IniRead($sIni, "Options", "SelfExtract", "0") = "1" Then $format = "exe"
    
    $command = StringReplace($command, " comp-mode ", " a ")
    If StringInStr($attrib, "D") Then
     $command = $command & '"' & $dir & "\" & $name & '.' & $format & '" ' & '"' & $file & '"'
    Else
     $command = $command & '"' & $dir & "\" & CutF($name) & $format & '" ' & '"' & $file & '"'
    EndIf
   EndIf
  Else
   $attrib = FileGetAttrib($file)
   If StringInStr($attrib, "D") Then
    $todo = 0
   Else
    ; check if file format is the correct one
    $temp = StringTrimLeft($name, StringLen(CutF($name)))
    If $temp = $format Then
     $todo = 1
    Else
     $todo = 0
    EndIf
   EndIf
   If $todo = 1 Then
    $password = IniRead($sIni, "Options", "TempPass", "default")
    
    ; check if archives are encrypted and ask the password
    While 1
     $commandT = '"' & @ScriptDir & '\data\FreeArc\Arc.exe" t -p' & $password & ' "' & $file & '"'
     $err = RunWait($commandT, "", @SW_HIDE)
     If $err = 0 Then
      ExitLoop
     Else
      $password = InsPass()
      IniWrite($sIni, "Options", "TempPass", $password)
     EndIf
     If $password = "none-lupo" Then
      $todo = 2
      Return $todo
     EndIf
    WEnd
    
    If $modality = "1" Then
     $command = StringReplace($command, " comp-mode ", " x ")
     $command = $command & '"-a' & $dir & '\" -p' & $password & ' "' & $file & '"'
    ElseIf $modality = "2" Then
     $command = StringReplace($command, " comp-mode ", " x ")
     $command = $command & '"-a' & $dir & '\' & CutF($name) & '\" -p' & $password & ' "' & $file & '"'
    Else
     $command = StringReplace($command, " comp-mode ", " e ")
     $command = $command & '"-a' & $dir & '\" -p' & $password & ' "' & $file & '"'
    EndIf
   EndIf
  EndIf
 EndIf
 
 If $todo = 1 Then
  If $show = 0 Then $process = Run($command, "", @SW_HIDE)
  If $show = 1 Then $process = Run($command, "", @SW_SHOW)
  ProcessSetPriority($command, 3)
 EndIf
 If $fff = 1 Then $todo = 1     ; set todo as 1 if the file is skipped for the format
 $i = 0
 While ProcessExists($process)
  If $i = 0 Then
   $i = 1
   GUICtrlSetData($textState, "Running")
   Sleep($wait)
  ElseIf $i = 1 Then
   $i = 2
   GUICtrlSetData($textState, "Running .")
   Sleep($wait)
  ElseIf $i = 2 Then
   $i = 3
   GUICtrlSetData($textState, "Running . .")
   Sleep($wait)
  ElseIf $i = 3 Then
   $i = 0
   GUICtrlSetData($textState, "Running . . .")
   Sleep($wait)
  EndIf
 WEnd
 Return $todo
EndFunc


Func ArcProcess($progressbar, $arcMode, $textState, $stop)          ; OK
 Local $j, $num, $part, $unit, $format, $modality, $command, $size, $a, $b, $todo, $file, $name, $dir, $parent
 Local $k = 0, $show = 0, $intell = 0
 ; $a = file name        $b = directory     $parent = parent folder         $k = file counter
 
 GUICtrlSetData($textState, "Running")
 
 ; command line creation
 $format = IniRead($sIni, "Options", "Format", "Arc")
 $modality = IniRead($sIni, "Options", "Modality", "1")
 If $format = "ARC" Then
  $command = SEZ_BuildCommand($arcMode)
 EndIf
 
 ; process
 If IniRead($sIni, "Options", "ShowConsole", "0") = "1" Then $show = 1
 If IniRead($sIni, "Options", "CompMode", "1") = "1" Then $intell = 1
 $dir = IniRead($sIni, "Options", "OutputDir", ".\archives")
 $num = _GUICtrlListView_GetItemCount($hListView)
 $part = 100/$num
 $unit = $part
 While 1
  If GUIGetMsg() = $stop Then
   GUICtrlSetData($progressbar, 100)
   ExitLoop
  Else
   $a = _GUICtrlListView_GetItemText($hListView, $k, 0)
   $b = _GUICtrlListView_GetItemText($hListView, $k, 1)
   $parent = _GUICtrlListView_GetItemParam($hListView, $k)
   $file = $b & $a
   $name = $a
   
   ; set the "own dir" if it is enabled
   If $format = "ARC" Then
    If IniRead($sIni, "Options", "OwnDir", "0") = "1" Then
     $dir = StringTrimRight($b, 1)
    EndIf
   EndIf
   
   $todo = ArcFile($format, $modality, $k, $command, $dir, $file, $name, $textState, $show, $intell, $arcMode, $parent)
   GUICtrlSetData($progressbar, $part+1)
   _GUICtrlListView_EnsureVisible($hListView, $k)
   
   ; update report column
   If $todo = 1 Then
    If $format = "ARC" Then
     If $arcMode = "comp" Then
      $attrib = FileGetAttrib($file)
      If IniRead($sIni, "Options", "SelfExtract", "0") = "1" Then $format = "exe"
      If StringInStr($attrib, "D") Then
       $temp = $dir & "\" & $name & "." & $format
       $size = FileGetSize($temp)
      Else
       $temp = $dir & "\" & CutF($name) & $format
       $size = FileGetSize($temp)
      EndIf
      If $format = "exe" Then $format = "ARC"
     Else
      $todo = 3
     EndIf
    EndIf
    If $todo = 3 Then
     _GUICtrlListView_SetItem($hListView, "OK", $k, 3)
    ElseIf $todo = 4 Then
     _GUICtrlListView_SetItem($hListView, '(' & ConvSize($size) & ')', $k, 3)
    Else
     _GUICtrlListView_SetItem($hListView, ConvSize($size), $k, 3)
    EndIf
   ElseIf $todo = 2 Then
    _GUICtrlListView_SetItem($hListView, "Failed", $k, 3)
   Else
    _GUICtrlListView_SetItem($hListView, "Skipped", $k, 3)
   EndIf
   
   $k = $k+1
   $part = $part + $unit
   If $k > ($num-1) Then
    ExitLoop
   EndIf
  EndIf
 WEnd
 IniDelete($sIni, "Options", "TempPass")
 GUICtrlSetData($textState, "Done")
EndFunc


Func InsPass()          ; OK
 ; window to insert the password of encrypted files
 Local $pww, $password, $sel, $ok, $canc, $pas
 
 $pww = GUICreate("Password", 190, 84, -1, -1)
 GUISetState(@SW_SHOW)
 GUISetIcon("arc.ico")
 GUICtrlCreateLabel("File encrypted, insert the password:", 11, 10, 180, 20)
 $pas = GUICtrlCreateInput("", 15, 30, 160, 20)
 $ok = GUICtrlCreateButton("OK", 25, 56, 60, 20, $BS_DEFPUSHBUTTON)
 $canc = GUICtrlCreateButton("Cancel", 105, 56, 60, 20)
 While 1
  $sel = GUIGetMsg()
  Switch $sel
   Case $GUI_EVENT_CLOSE
    $password = "none-lupo"
    ExitLoop
    
   Case $ok
    $password = GUICtrlRead($pas)
    ExitLoop
    
   Case $canc
    $password = "none-lupo"
    ExitLoop
    
  EndSwitch
 WEnd
 GUIDelete($pww)
 Return $password
EndFunc


Func RefreshCombo($combo, $List, $Mod)          ; OK

 $combo = GUICtrlCreateCombo("", 11, 268, 149, 20)
 GUICtrlSetData($combo, $List, $Mod)
 Return $combo
EndFunc


Func LoadResult()           ; OK
 Local $file, $a, $b, $k, $size
 ; $a = file name        $b = directory     $k = file counter
 
 For $k = 0 To _GUICtrlListView_GetItemCount($hListView)
  $temp = _GUICtrlListView_GetItemText($hListView, $k, 3)
  If Not StringInStr($temp, "-") And Not StringInStr($temp, "Sk") And Not StringInStr($temp, "Fa") And Not StringInStr($temp, "OK") Then
   $a = _GUICtrlListView_GetItemText($hListView, $k, 0)
   $b = _GUICtrlListView_GetItemText($hListView, $k, 1)
   $file = $b & $a
   $attrib = FileGetAttrib($file)
   If StringInStr($attrib, "D") Then
    $size = DirGetSize($file)
   Else
    $size = FileGetSize($file)
   EndIf
   _GUICtrlListView_SetItem($hListView, ConvSize($size), $k, 2)
  EndIf
  _GUICtrlListView_SetItem($hListView, " - ", $k, 3)
 Next
EndFunc


Func ClearResult()          ; OK

 For $i = 0 To _GUICtrlListView_GetItemCount($hListView)
  _GUICtrlListView_SetItem($hListView, " - ", $i, 3)
 Next
EndFunc


Func DuplicateCheck($item)      ; OK ??
 Local $nIt, $k, $a, $b, $aa, $bb
 
 $nIt = _GUICtrlListView_GetItemCount($hListView)
 $aa = _GUICtrlListView_GetItemText($hListView, $item, 0)
 $bb = _GUICtrlListView_GetItemText($hListView, $item, 1)
 For $k = 0 To $nIt - 1
  If Not ($k = $item) Then
   $a = _GUICtrlListView_GetItemText($hListView, $k, 0)
   $b = _GUICtrlListView_GetItemText($hListView, $k, 1)
   If $a = $aa Then
    If $b = $bb Then
     _GUICtrlListView_SetItemParam($hListView, $item, 2)
     ;GUICtrlSetBkColor($item, 0xFFBFBF)
    EndIf
   EndIf
  EndIf
 Next
EndFunc


Func DuplicateDel()         ; OK
 Local $k, $d, $n, $decision = 0
 
 $n = _GUICtrlListView_GetItemCount($hListView)
 For $k = 1 To $n
  $d = _GUICtrlListView_GetItemParam($hListView, $n - $k)
  If $d = 2 Then
   If $decision = 0 Then
    $decision = MsgBox(0x40004, "Duplicates detected", "Some duplicate files detected, do you want to keep only one copy of them?")
   EndIf
   If $decision = 6 Then
    ; remove the item
    GUICtrlSendMsg($hListView, 0x1008, $n - $k, 0)
    ; remove from the counter
    $count = $count - 1
    GUICtrlSetData($counter, $count)
   EndIf
  EndIf
 Next
EndFunc


Func SetMode($combo)            ; OK
 Local $format, $modality

 $format = IniRead($sIni, "Options", "Format", "ARC")
 If $format = "ARC" Then
  $modality = GUICtrlRead($combo)
  If $modality = "Normal compression" Or $modality = "Normal extraction" Then
   IniWrite($sIni, "Options", "Modality", "1")
  ElseIf $modality = "Single archive per file" Or $modality = "New folder each archive" Then
   IniWrite($sIni, "Options", "Modality", "2")
  ElseIf $modality = "Single archive per folder" Or $modality = "All in main folder" Then
   IniWrite($sIni, "Options", "Modality", "3")
  EndIf
 EndIf
EndFunc


Func Cut($temp)         ; OK
 ; cut the last subdir from dir string
 Local $c
 
 $c = StringRight($temp, 1)
 While 1
  If $c = "\" Then
   ExitLoop
  Else
   $temp = StringTrimRight($temp, 1)
   $c = StringRight($temp, 1)
  EndIf
 WEnd
 Return $temp
EndFunc


Func CutF($temp)            ; OK
 ; cut format from the name string
 Local $c
 
 $c = StringRight($temp, 1)
 While 1
  If $c = "." Then
   ExitLoop
  Else
   $temp = StringTrimRight($temp, 1)
   $c = StringRight($temp, 1)
  EndIf
 WEnd
 Return $temp
EndFunc


Func Add($temp, $mainf)         ; OK ??
 Local $search, $file, $size, $subtemp, $main, $dir
 
 ; Parameters:   0 = none   1 = parent   2 = duplicate
 
 If $mainf = 2 Then
  ; load only one file
  $main = StringTrimLeft($temp, StringLen(Cut($temp)))
  $size = FileGetSize($temp)
  $dir = StringTrimRight(Cut($temp), 1) & "\"
  $item = _GUICtrlListView_AddItem($hListView, $main, -1, 0)
  _GUICtrlListView_AddSubItem($hListView, $item, $dir, 1)
  _GUICtrlListView_AddSubItem($hListView, $item, ConvSize($size), 2)
  _GUICtrlListView_AddSubItem($hListView, $item, " - ", 3)
  
  ; check if new item is a duplicate
  If IniRead($sIni, "Options", "CheckDuplicates", "1") = "1" Then DuplicateCheck($item)
  
  ; add to the counter
  $count = $count + 1
  GUICtrlSetData($counter, $count)
 Else
  ; load main folder
  If $mainf = 0 Then
   $mainf = 1
   $main = StringTrimLeft($temp, StringLen(Cut($temp)))
   $size = DirGetSize($temp & "\" & $file)
   $dir = Cut($temp)
   $item = _GUICtrlListView_AddItem($hListView, $main, -1, 1)
   _GUICtrlListView_AddSubItem($hListView, $item, $dir, 1)
   _GUICtrlListView_AddSubItem($hListView, $item, ConvSize($size), 2)
   _GUICtrlListView_AddSubItem($hListView, $item, " - ", 3)
   ;GUICtrlSetBkColor($item, 0xE5F7FF)
   
   ; check if new item is a duplicate
   If IniRead($sIni, "Options", "CheckDuplicates", "1") = "1" Then DuplicateCheck($item)
   
   ; add to the counter
   $count = $count + 1
   GUICtrlSetData($counter, $count)
  EndIf
 
  ; load files
  $search = FileFindFirstFile($temp & "\*.*")
  While 1
   $file = FileFindNextFile($search)
   If @error Then ExitLoop
   $attrib = FileGetAttrib($temp & "\" & $file)
   If Not StringInStr($attrib, "D") Then
    $size = FileGetSize($temp & "\" & $file)
    $dir = $temp & "\"
    $item = _GUICtrlListView_AddItem($hListView, $file, -1, 0)
    _GUICtrlListView_AddSubItem($hListView, $item, $dir, 1)
    _GUICtrlListView_AddSubItem($hListView, $item, ConvSize($size), 2)
    _GUICtrlListView_AddSubItem($hListView, $item, " - ", 3)
    
    ; check if new item is a duplicate
    If IniRead($sIni, "Options", "CheckDuplicates", "1") = "1" Then DuplicateCheck($item)
    
    ; add to the counter
    $count = $count + 1
    GUICtrlSetData($counter, $count)
   EndIf
  WEnd
  FileClose($search)
  
  ; load folders
  $search = FileFindFirstFile($temp & "\*.*")
  While 1
   $file = FileFindNextFile($search)
   If @error Then ExitLoop
   $attrib = FileGetAttrib($temp & "\" & $file)
   If StringInStr($attrib, "D") Then
    $size = DirGetSize($temp & "\" & $file)
    $dir = $temp & "\"
    $item = _GUICtrlListView_AddItem($hListView, $file, -1, 0)
    _GUICtrlListView_AddSubItem($hListView, $item, $dir, 1)
    _GUICtrlListView_AddSubItem($hListView, $item, ConvSize($size), 2)
    _GUICtrlListView_AddSubItem($hListView, $item, " - ", 3)
    ;GUICtrlSetBkColor($item, 0xE5F7FF)
    
    ; check if new item is a duplicate
    If IniRead($sIni, "Options", "CheckDuplicates", "1") = "1" Then DuplicateCheck($item)
    
    $subtemp = $temp & "\" & $file
    Add($subtemp, $mainf)
    ; add to the counter
    $count = $count + 1
    GUICtrlSetData($counter, $count)
   EndIf
  WEnd
  FileClose($search)
 EndIf
EndFunc


Func Options($GUI)          ; OK
 Local $opz, $sel, $ok, $canc
 Local $top, $aut, $exit, $mode1, $mode2, $mode3, $chk, $bak, $cc1, $cc2, $cc3, $cc4, $show, $sfx, $enc, $pas, $pw
 $opz = GUICreate("Options", 404, 264, -1, -1, -1, $WS_EX_TOOLWINDOW, $GUI)
 GUISetState()
 
 ; general options
 GUICtrlCreateGroup("General Options", 8, 8, 190, 86)
 $top = GUICtrlCreateCheckbox("Always on top", 16, 24, 170, 20)
 $aut = GUICtrlCreateCheckbox("Auto compress after loading", 16, 24+22, 170, 20)
 $exit = GUICtrlCreateCheckbox("Exit when done", 16, 24+44, 170, 20)
 GUICtrlCreateGroup("", -99, -99, 1, 1)  ;close group
 


 
 ; other options
 GUICtrlCreateGroup("Other Options", 198+8, 94+8, 190, 86+44)
 $chk = GUICtrlCreateCheckbox("Check duplicates in the list", 198+16, 94+24, 170, 20)
 GUICtrlSetTip($chk, "It make loading process slower")
 $show = GUICtrlCreateCheckbox("Show console window", 198+16, 94+24+22, 170, 20)
 $sfx = GUICtrlCreateCheckbox("Create self-extracting archives", 198+16, 94+24+44, 170, 20)
 GUICtrlSetTip($sfx, "It works only compressing with 7z format")
 $enc = GUICtrlCreateCheckbox("Encrypt 7z and zip archives", 198+16, 94+24+66, 170, 20)
 GUICtrlSetTip($enc, "For security reasons it is cleaned at any startup")
 $pw = GUICtrlCreateLabel("Password:", 198+16, 94+24+88, 52, 20)
 GUICtrlSetState($pw, $GUI_DISABLE)
 $temp = IniRead($sIni, "Options", "Password", "")
 $pas = GUICtrlCreateInput($temp, 198+16+54, 94+24+86, 120, 18)
 GUICtrlSetState($pas, $GUI_DISABLE)
 GUICtrlCreateGroup("", -99, -99, 1, 1)  ;close group
 
 ; import ini settings
 If IniRead($sIni, "Options", "AlwaysOnTop", "0") = "1" Then GUICtrlSetState($top, 1)
 If IniRead($sIni, "Options", "AutoComp", "0") = "1" Then GUICtrlSetState($aut, 1)
 If IniRead($sIni, "Options", "ExitDone", "0") = "1" Then GUICtrlSetState($exit, 1)
 If IniRead($sIni, "Options", "Backup", "0") = "1" Then GUICtrlSetState($bak, 1)
 If IniRead($sIni, "Options", "CompIcons", "1") = "1" Then GUICtrlSetState($cc1, 1)
 If IniRead($sIni, "Options", "CompExports", "1") = "1" Then GUICtrlSetState($cc2, 1)
 If IniRead($sIni, "Options", "CompResources", "1") = "1" Then GUICtrlSetState($cc3, 1)
 If IniRead($sIni, "Options", "StripRelocs", "1") = "1" Then GUICtrlSetState($cc4, 1)
 If IniRead($sIni, "Options", "CompMode", "1") = "1" Then
  GUICtrlSetState($mode1, 1)
 ElseIf IniRead($sIni, "Options", "CompMode", "1") = "2" Then
  GUICtrlSetState($mode2, 1)
 Else
  GUICtrlSetState($mode3, 1)
 EndIf
 If IniRead($sIni, "Options", "CheckDuplicates", "1") = "1" Then GUICtrlSetState($chk, 1)
 If IniRead($sIni, "Options", "ShowConsole", "0") = "1" Then GUICtrlSetState($show, 1)
 If IniRead($sIni, "Options", "SelfExtract", "0") = "1" Then GUICtrlSetState($sfx, 1)
 If IniRead($sIni, "Options", "Encrypt", "0") = "1" Then
  GUICtrlSetState($enc, 1)
  GUICtrlSetState($pw, $GUI_ENABLE)
  GUICtrlSetState($pas, $GUI_ENABLE)
 Else
  GUICtrlSetState($enc, 0)
 EndIf
 
 $ok = GUICtrlCreateButton("OK", 100, 236, 78, 22, $BS_DEFPUSHBUTTON)
 $canc = GUICtrlCreateButton("Cancel", 226, 236, 78, 22)
 While 1
  $sel = GUIGetMsg()
  Switch $sel
   Case $GUI_EVENT_CLOSE
    ExitLoop
    
   Case $enc
    If GUICtrlRead($enc) = $GUI_CHECKED Then
     GUICtrlSetState($pw, $GUI_ENABLE)
     GUICtrlSetState($pas, $GUI_ENABLE)
    Else
     GUICtrlSetState($pw, $GUI_DISABLE)
     GUICtrlSetState($pas, $GUI_DISABLE)
    EndIf
    
   Case $ok
    If GUICtrlRead($top) = 1 Then
     IniWrite($sIni, "Options", "AlwaysOnTop", "1")
     WinSetOnTop(" ArcThemAll! ", "", 1)
    Else
     IniWrite($sIni, "Options", "AlwaysOnTop", "0")
     WinSetOnTop(" ArcThemAll! ", "", 0)
    EndIf
    If GUICtrlRead($aut) = 1 Then
     IniWrite($sIni, "Options", "AutoComp", "1")
    Else
     IniWrite($sIni, "Options", "AutoComp", "0")
    EndIf
    If GUICtrlRead($exit) = 1 Then
     IniWrite($sIni, "Options", "ExitDone", "1")
    Else
     IniWrite($sIni, "Options", "ExitDone", "0")
    EndIf
    If GUICtrlRead($bak) = 1 Then
     IniWrite($sIni, "Options", "Backup", "1")
    Else
     IniWrite($sIni, "Options", "Backup", "0")
    EndIf
    If GUICtrlRead($cc1) = 1 Then
     IniWrite($sIni, "Options", "CompIcons", "1")
    Else
     IniWrite($sIni, "Options", "CompIcons", "0")
    EndIf
    If GUICtrlRead($cc2) = 1 Then
     IniWrite($sIni, "Options", "CompExports", "1")
    Else
     IniWrite($sIni, "Options", "CompExports", "0")
    EndIf
    If GUICtrlRead($cc3) = 1 Then
     IniWrite($sIni, "Options", "CompResources", "1")
    Else
     IniWrite($sIni, "Options", "CompResources", "0")
    EndIf
    If GUICtrlRead($cc4) = 1 Then
     IniWrite($sIni, "Options", "StripRelocs", "1")
    Else
     IniWrite($sIni, "Options", "StripRelocs", "0")
    EndIf
    If GUICtrlRead($mode1) = 1 Then IniWrite($sIni, "Options", "CompMode", "1")
    If GUICtrlRead($mode2) = 1 Then IniWrite($sIni, "Options", "CompMode", "2")
    If GUICtrlRead($mode3) = 1 Then IniWrite($sIni, "Options", "CompMode", "3")
    If GUICtrlRead($chk) = 1 Then
     IniWrite($sIni, "Options", "CheckDuplicates", "1")
    Else
     IniWrite($sIni, "Options", "CheckDuplicates", "0")
    EndIf
    If GUICtrlRead($show) = 1 Then
     IniWrite($sIni, "Options", "ShowConsole", "1")
    Else
     IniWrite($sIni, "Options", "ShowConsole", "0")
    EndIf
    If GUICtrlRead($sfx) = 1 Then
     IniWrite($sIni, "Options", "SelfExtract", "1")
    Else
     IniWrite($sIni, "Options", "SelfExtract", "0")
    EndIf
    If GUICtrlRead($enc) = 1 Then
     IniWrite($sIni, "Options", "Encrypt", "1")
     IniWrite($sIni, "Options", "Password", GUICtrlRead($pas))
     If GUICtrlRead($pas) = "" Then
      MsgBox(0x40000, "Message", "You have to enter a password for the encrypt mode or uncheck it.")
     Else
      ExitLoop
     EndIf
    Else
     IniWrite($sIni, "Options", "Encrypt", "0")
     IniWrite($sIni, "Options", "Password", GUICtrlRead($pas))
     ExitLoop
    EndIf
    
   Case $canc
    ExitLoop
    
  EndSwitch
 WEnd
 GUIDelete($opz)
EndFunc


Func Lister()           ; OK

 $hListView = GUICtrlCreateListView($upp, 11, 43, 455, 190, $LVS_NOSORTHEADER, $WS_EX_CLIENTEDGE)
 GUICtrlSetState($hListView, $GUI_DROPACCEPTED)
 _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOr($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_INFOTIP))
 
 ; make tips visible on top
 Local $hToolTip = _GUICtrlListView_GetToolTips($hListView)
 If IsHWnd($hToolTip) Then
  WinSetOnTop($hToolTip, "", 1)
  _GUIToolTip_SetDelayTime($hToolTip, 3, 60) ; speeds up infotip appearance
 EndIf
EndFunc


Func Output($GUI)           ; OK
 Local $outp, $sel, $ok, $canc, $brows, $help
 Local $directory, $dir, $own_dir, $tp = 0
 $outp = GUICreate("Choose output directory", 300, 96, -1, -1, -1, $WS_EX_TOOLWINDOW, $GUI)
 GUISetState()
 
 $dir = IniRead($sIni, "Options", "OutputDir", ".\archives")
 $directory = GUICtrlCreateInput($dir, 8, 11, 224, 20)
 $brows = GUICtrlCreateButton("Browse", 238, 10, 54, 22)
 
 $own_dir = GUICtrlCreateCheckbox("Use the directory of each file loaded", 10, 37, 200, 20)
 If IniRead($sIni, "Options", "OwnDir", "0") = "1" Then
  GUICtrlSetState($own_dir, 1)
  GUICtrlSetState($directory, $GUI_DISABLE)
  GUICtrlSetState($brows, $GUI_DISABLE)
 EndIf
 
 $help = GUICtrlCreateButton("Help", 20, 65, 64, 22)
 $ok = GUICtrlCreateButton("OK", 140, 65, 64, 22, $BS_DEFPUSHBUTTON)
 $canc = GUICtrlCreateButton("Cancel", 220, 65, 64, 22)
 While 1
  $sel = GUIGetMsg()
  Switch $sel
   Case $GUI_EVENT_CLOSE
    ExitLoop
    
   Case $brows
    If IniRead($sIni, "Options", "AlwaysOnTop", "0") = "1" Then
     WinSetOnTop(" ArcThemAll! ", "", 0)
     $tp = 1
    EndIf
    $temp = FileSelectFolder("Choose a directory:", "", 3)
    If Not $temp = "" Then GUICtrlSetData($directory, $temp)
    If $tp = 1 Then WinSetOnTop(" ArcThemAll! ", "", 1)
    GUICtrlSetState($ok, $GUI_FOCUS)
    
   Case $own_dir
    If GUICtrlRead($own_dir) = 1 Then
     GUICtrlSetState($directory, $GUI_DISABLE)
     GUICtrlSetState($brows, $GUI_DISABLE)
    Else
     GUICtrlSetState($directory, $GUI_ENABLE)
     GUICtrlSetState($brows, $GUI_ENABLE)
    EndIf
    
   Case $help
    MsgBox(0x40000, "Help", 'You can use absolute paths, relative paths (ex: ".\dir" and "..\dir"), or the directory of each file loaded (to create output files in source directories).')
    GUICtrlSetState($ok, $GUI_FOCUS)
   
   Case $ok
    IniWrite($sIni, "Options", "OutputDir", GUICtrlRead($directory))
    If GUICtrlRead($own_dir) = 1 Then
     IniWrite($sIni, "Options", "OwnDir", "1")
    Else
     IniWrite($sIni, "Options", "OwnDir", "0")
    EndIf
    ExitLoop
   
   Case $canc
    ExitLoop
    
  EndSwitch
 WEnd
 GUIDelete($outp)
EndFunc


Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam)         ; OK
 ;Author: Lazycat
 Local $nSize, $pFileName
 Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255)
 For $i = 0 To $nAmt[0] - 1
  $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0)
  $nSize = $nSize[0] + 1
  $pFileName = DllStructCreate("char[" & $nSize & "]")
  DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize)
  ReDim $gaDropFiles[$i+1]
  $gaDropFiles[$i] = DllStructGetData($pFileName, 1)
  $pFileName = 0
 Next
EndFunc


Func _Main()
 Local $GUI, $add, $del, $clear, $combo, $progressbar, $go, $stop, $options, $about, $arc
 Local $radio1, $r1, $radio2, $r2, $rad1, $rr1, $rad2, $rr2, $rad3, $rr3
 Local $msg, $format, $modality, $Mod, $List, $out, $dir, $array[5], $arcMode, $textState, $first = 0
 
 $GUI = GUICreate(" ArcThemAll! ", 478, 336, -1, -1, -1, $WS_EX_ACCEPTFILES)
 GUISetIcon("arc.ico")
 GUISetBkColor(0x121566)
 GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES_FUNC")
 
 ; set priority of the app
 ProcessSetPriority(@AutoItPID, 3)
 
 ; top buttons
 $radio1 = GUICtrlCreateRadio("", 26, 14, 18, 20)
 GUICtrlSetState(-1, $GUI_HIDE)
 $r1 = GUICtrlCreateLabel("Compress", 44, 16, 60, 20)
 GUICtrlSetState(-1, $GUI_HIDE)
 GUICtrlSetFont($r1, 9, 400)
 $radio2 = GUICtrlCreateRadio("", 126, 14, 18, 20)
 GUICtrlSetState(-1, $GUI_HIDE)
 $r2 = GUICtrlCreateLabel("Decompress", 144, 16, 80, 20)
 GUICtrlSetState(-1, $GUI_HIDE)
 GUICtrlSetFont($r2, 9, 400)
 $add = GUICtrlCreateButton("+", 298, 11, 24, 24, $BS_ICON)
 GUICtrlSetImage($add, @ScriptDir & "\data\ico\1.ico")
 GUICtrlSetTip($add, 'Add items to the list')
 $del = GUICtrlCreateButton("-", 328, 11, 24, 24, $BS_ICON)
 GUICtrlSetImage($del, @ScriptDir & "\data\ico\2.ico")
 GUICtrlSetTip($del, 'Remove selected items from the list')
 $clear = GUICtrlCreateButton("x", 358, 11, 24, 24, $BS_ICON)
 GUICtrlSetImage(-1, @ScriptDir & "\data\ico\3.ico")
 GUICtrlSetTip($clear, 'Clear the list of items')
 $out = GUICtrlCreateButton("Output", 400, 11, 67, 24)
 GUICtrlSetTip($out, 'Change the output directory')
 
 ; list view
 Lister()
 
 ; create ini
 If Not FileExists($sIni) Then
  $sData = "Arc=compress" & @LF & "Format=ARC" & @LF & "Modality=1" & @LF & "AlwaysOnTop=0" & @LF & "AutoComp=0" & @LF & "ExitDone=0" & @LF & "Backup=0" & @LF & "CompIcons=1" & @LF & "CompExports=1" & @LF & "CompResources=1" & @LF & "StripRelocs=1" & @LF & "CompMode=1" & @LF & "CheckDuplicates=1" & @LF & "ShowConsole=0" & @LF & "SelfExtract=0" & @LF & "Encrypt=0" & @LF & "Password=" & @LF & "OutputDir=.\archives" & @LF & "OwnDir=0"
  IniWriteSection($sIni, "Options", $sData)
 EndIf
 
 ; formats
 $rad3 = GUICtrlCreateRadio("", 104, 242, 16, 20)
 GUICtrlSetState(-1, $GUI_HIDE)
 $rr3 = GUICtrlCreateLabel("ARC", 121, 243, 30, 20)
 GUICtrlSetState(-1, $GUI_HIDE)
 GUICtrlSetFont($rr3, 9, 400)
 GUICtrlCreateGroup("", -99, -99, 1, 1)
 
 ; import format and compression mode
 $arc = IniRead($sIni, "Options", "Arc", "compress")
 $format = IniRead($sIni, "Options", "Format", "ARC")
 $modality = IniRead($sIni, "Options", "Modality", "1")
 If $arc = "compress" Then
  GUICtrlSetState($radio1, $GUI_CHECKED)
  If $format = "ARC" Then
   GUICtrlSetState($out, $GUI_ENABLE)
   GUICtrlSetState($rad3, $GUI_CHECKED)
   If $modality = "1" Then
    $Mod = "Normal compression"
   ElseIf $modality = "2" Then
    $Mod = "Single archive per file"
   Else
    $Mod = "Single archive per folder"
   EndIf
   $List = $zipList
   $combo = RefreshCombo($combo, $List, $Mod)
  EndIf
 Else
  GUICtrlSetState($radio2, $GUI_CHECKED)
  If $format = "ARC" Then
   GUICtrlSetState($out, $GUI_ENABLE)
   GUICtrlSetState($rad3, $GUI_CHECKED)
   If $modality = "1" Then
    $Mod = "Normal extraction"
   ElseIf $modality = "2" Then
    $Mod = "New folder each archive"
   Else
    $Mod = "All in main folder"
   EndIf
   $List = $zipListD
   $combo = RefreshCombo($combo, $List, $Mod)
  EndIf
 EndIf
 
 ; set always on top
 If IniRead($sIni, "Options", "AlwaysOnTop", "0") = "1" Then WinSetOnTop(" ArcThemAll! ", "", 1)
 
 ; GUI elements
 $go = GUICtrlCreateButton("GO!", 178, 241, 180, 50, $BS_DEFPUSHBUTTON)
 GUICtrlSetFont($go, 23, 400)
 $options = GUICtrlCreateButton("Options", 377, 241, 90, 22)
 $about = GUICtrlCreateButton("About", 377, 269, 90, 22)
 $progressbar = GUICtrlCreateProgress(11, 299, 455, 14)
 $textState = GUICtrlCreateLabel(" ", 34, 317, 300, 16)
 GUICtrlSetColor($textState, 0xE5E5E5)
 GUICtrlCreateLabel("Items:", 390, 317, 30, 16)
 GUICtrlSetColor(-1, 0xE5E5E5)
 $counter = GUICtrlCreateLabel("0", 423, 317, 30, 16)
 GUICtrlSetColor($counter, 0xE5E5E5)
 
 GUISetState()
 While 1
  $msg = GUIGetMsg()
  Switch $msg
   Case $GUI_EVENT_CLOSE
    ; set format and compression mode
    SetMode($combo)
    If GUICtrlRead($radio1) = $GUI_CHECKED Then
     IniWrite($sIni, "Options", "Arc", "compress")
    Else
     IniWrite($sIni, "Options", "Arc", "decompress")
    EndIf
    IniWrite($sIni, "Options", "Encrypt", "0")
    IniWrite($sIni, "Options", "Password", "")
    ExitLoop
    
   Case $radio1
    ControlClick("", "", $r1)
   
   Case $r1
    GUICtrlSetState($radio1, $GUI_CHECKED)
    GUICtrlSetState($radio2, $GUI_UNCHECKED)
    If GUICtrlRead($rad2) = $GUI_CHECKED Or GUICtrlRead($rad3) = $GUI_CHECKED Then
     $Mod = $zipMod
     $List = $zipList
     GUICtrlDelete($combo)
     $combo = RefreshCombo($combo, $List, $Mod)
    EndIf
    
   Case $radio2
    ControlClick("", "", $r2)
    
   Case $r2
    GUICtrlSetState($radio1, $GUI_UNCHECKED)
    GUICtrlSetState($radio2, $GUI_CHECKED)
    If GUICtrlRead($rad2) = $GUI_CHECKED Or GUICtrlRead($rad3) = $GUI_CHECKED Then
     $Mod = $zipModD
     $List = $zipListD
     GUICtrlDelete($combo)
     $combo = RefreshCombo($combo, $List, $Mod)
    EndIf
    
 
   Case $rad3
    ControlClick("", "", $rr3)
    
   Case $rr3
    GUICtrlSetState($rad1, $GUI_UNCHECKED)
    GUICtrlSetState($rad2, $GUI_UNCHECKED)
    GUICtrlSetState($rad3, $GUI_CHECKED)
    GUICtrlSetState($out, $GUI_ENABLE)
    IniWrite($sIni, "Options", "Format", "ARC")
    If GUICtrlRead($radio1) = $GUI_CHECKED Then
     $Mod = $zipMod
     $List = $zipList
    Else
     $Mod = $zipModD
     $List = $zipListD
    EndIf
    GUICtrlDelete($combo)
    $combo = RefreshCombo($combo, $List, $Mod)
    
   Case $GUI_EVENT_DROPPED
    GUICtrlSetData($textState, "Loading")
    For $i = 0 To UBound($gaDropFiles) - 1
     $temp = $gaDropFiles[$i]
     If StringInStr(FileGetAttrib($temp), "D") Then
      $mainf = 0
      Add($temp, $mainf)
     Else
      $mainf = 2
      Add($temp, $mainf)
     EndIf
    Next
    DuplicateDel()
    GUICtrlSetData($textState, "Ready to start")
    If IniRead($sIni, "Options", "AutoComp", "0") = "1" Then
     Sleep(100)
     ControlClick("", "", $go)
    EndIf
    
   Case $add
    GUICtrlSetData($textState, "Loading")
    GUICtrlSetState($go, $GUI_FOCUS)
    $temp = FileSelectFolder("Select a folder of items to add.", "")
    If Not $temp = "" Then
     $mainf = 0
     Add($temp, $mainf)
    EndIf
    DuplicateDel()
    GUICtrlSetData($textState, "Ready to start")
    If IniRead($sIni, "Options", "AutoComp", "0") = "1" Then
     Sleep(100)
     ControlClick("", "", $go)
    EndIf
    
   Case $del
    GUICtrlSetState($go, $GUI_FOCUS)
    _GUICtrlListView_DeleteItemsSelected(GUICtrlGetHandle($hListView))
    ; set the counter
    $count = _GUICtrlListView_GetItemCount($hListView)
    GUICtrlSetData($counter, $count)
    If _GUICtrlListView_GetItemCount($hListView) = 0 Then GUICtrlSetData($textState, " ")
   
   Case $clear
    GUICtrlSetState($go, $GUI_FOCUS)
    GUICtrlDelete($hListView)
    ; set the counter
    $count = 0
    GUICtrlSetData($counter, $count)
    GUICtrlSetData($textState, " ")
    $first = 0
    Lister()
   
   Case $out
    Output($GUI)
    GUICtrlSetState($go, $GUI_FOCUS)
    
   Case $go
    ; set format and compression mode
    SetMode($combo)
    
    ; check if compress or decompress
    If GUICtrlRead($radio1) = $GUI_CHECKED Then
     IniWrite($sIni, "Options", "Arc", "compress")
     $arcMode = "comp"
    Else
     IniWrite($sIni, "Options", "Arc", "decompress")
     $arcMode = "decomp"
    EndIf
    
    If Not _GUICtrlListView_GetItemCount($hListView) = 0 Then
     GUICtrlSetState($options, $GUI_DISABLE)
     GUICtrlSetState($about, $GUI_DISABLE)
     
     ; clear/upload results column
     If $first = 0 Then
      ClearResult()
      $first = 1
     Else
      LoadResult()
     EndIf
     
     ; create the STOP button
     $stop = GUICtrlCreateButton("STOP", 178, 241, 180, 50, $BS_DEFPUSHBUTTON)
     GUICtrlSetFont($stop, 18, 400)
     GUICtrlDelete($go)
     
     ; start archiviation process
     ArcProcess($progressbar, $arcMode, $textState, $stop)
     
     ; recreate the GO button
     $go = GUICtrlCreateButton("GO!", 178, 241, 180, 50, $BS_DEFPUSHBUTTON)
     GUICtrlSetFont($go, 23, 400)
     GUICtrlDelete($stop)
    EndIf
    GUICtrlSetState($options, $GUI_ENABLE)
    GUICtrlSetState($about, $GUI_ENABLE)
    
    ; automatically exit if setted
    If IniRead($sIni, "Options", "ExitDone", "0") = "1" Then
     SetMode($combo)
     IniWrite($sIni, "Options", "Encrypt", "0")
     IniWrite($sIni, "Options", "Password", "")
     ExitLoop
    EndIf
    
   Case $options
    Options($GUI)
    GUICtrlSetState($go, $GUI_FOCUS)
    
   Case $about
    MsgBox(0x40000, "About", "       " & $version & @LF & @LF & "Software developed by Lupo PenSuite Team." & @LF & "Released under Open Source GPL.")
    GUICtrlSetState($go, $GUI_FOCUS)
   
  EndSwitch
 WEnd
EndFunc

 

Edited by OmarPapi
Link to comment
Share on other sites

OK that's a start, now what is your problem?

Answering that will greatly improve your chances of a helpful response.

Feel free to add further information without having to be asked questions.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

JohnOne

the compressed folder created with this script in it creates references to the former directory: user \ administrator \ desktop \ folder \ and then displays the files.
I wish that by opening the compressed file there are these rumors but only compressed files

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