The superior speed and compression of 7-zip can be called with AHK and it can work in the background (both the -hide parameter and RegisterCallBack method are supported - see examples included.)
This dll is based on the latest 7-zip (version 9.20)
Also, no need to go figure out the command line 8). The options can easily be set with the Object.opt properties (see doc).
Discovered way back in this post and also here. Anyway, here is the library.
â–º Download Library:7-zip32.7z + Dll: Official Site/AHK.net â–º Documentation
Reference:
Dll Site: <!-- m -->http://www.madobe.ne...er/index-e.html<!-- m -->
Dll API : <!-- m -->http://www.madobe.ne...zip32api-en.txt<!-- m -->
Dll Japanese site: <!-- m -->http://www.csdinc.co...ib/7-zip32.html<!-- m -->
7-zip cmdline reference: <!-- m -->http://sevenzip.sour...jp/chm/cmdline/<!-- m -->
Basic Example
/* Function: Basic 7-zip32.dll library example Requires: 7Zip.ahk (include or in Std Library) and AHK_L URL: http://www.autohotkey.com/forum/viewtopic.php?t=69249 */ If !( o7z := 7Zip_Init() ) Quit("Failed loading 7-zip32.dll library") o7z.opt.Hide := 1 ;You can enable it to hide process dialog MsgBox % 7Zip_GetVersion() FileSelectFile,sArcFile, S16,,Create archive as..,Archives (*.zip; *.7z; *.bzip2; *.tar; *.iso; *.udf; *.gzip) FileSelectFolder, sFolder,,0,Select folder to archive MsgBox % 7Zip_Add(sArcFile, sFolder) ;Add to archive MsgBox % 7Zip_List(sArcFile) ;List files in archive FileSelectFolder, sFolder,,3,Select folder to extract to o7z.opt.Output := sFolder ;Set output folder MsgBox % 7Zip_Extract(sArcFile) ;Extract files 7Zip_Close() ExitApp Quit(Msg) { MsgBox % Msg ExitApp } #Include 7zip.ahk
Basic Callback Example:
/* Function: Example Add files to archive with callback Requires: 7Zip.ahk (include or in Std Library) and AHK_L URL: http://www.autohotkey.com/forum/viewtopic.php?t=69249 */ gui, +LastFound hMyWnd := WinExist() o7z := 7Zip_Init() o7z.opt.Hide := 1 ;Required for callback mode FileSelectFile,sArcFile, S16,,Create archive as..,Archives (*.zip; *.7z; *.bzip2; *.tar; *.iso; *.udf; *.gzip) FileSelectFolder, sFolder,,0,Select folder to archive If !7Zip_SetOwnerWindowEx("Fn_ARCHIVERPROC", hMyWnd) Quit("Could not create callback") 7Zip_Add(sArcFile, sFolder, hMyWnd) Sleep 100 While !7Zip_ProcessComplete Sleep 200 MsgBox, Archive created successfully! FileSelectFolder, sFolder,,3,Select folder to extract to o7z.opt.Output := sFolder r := 7Zip_Extract(sArcFile, hMyWnd) ; MsgBox % r Sleep 100 While !7Zip_ProcessComplete Sleep 200 MsgBox, Archive extracted successfully! ExitApp Fn_ARCHIVERPROC(hWnd, Msg, nState, ExInfo) { global 7Zip_ProcessComplete = 0 Critical iPercent := 0 If !nState { iFileSize := NumGet(ExInfo+0, 0, "UInt") iWriteSize := NumGet(ExInfo+0, 4, "UInt") iSourceFileName := StrGet(ExInfo+8,513,"CP0") iDestFileName := StrGet(ExInfo+524,513,"CP0") iCompressedSize := NumGet(ExInfo+0, 1040, "UInt") iCRC := NumGet(ExInfo+0, 1044, "UInt") iRatio := NumGet(ExInfo+0, 1052, "UShort") iDate := NumGet(ExInfo+0, 1054, "UShort") iTime := NumGet(ExInfo+0, 1056, "UShort") iAttribute := StrGet(ExInfo+1058,8,"CP0") iMode := StrGet(ExInfo+1066,8,"CP0") iPercent := (iWriteSize/iFileSize) * 100 FileAppend, % "" . iSourceFileName . " - " . iDestFileName . " " . iPercent . "% Compressed Size:" . iCompressedSize . " CRC:" . iCRC . " Ratio:" . iRatio . " Attribute:" . iAttribute . " Mode:" . iMode . "`n" , * ;output to console Critical, Off Return 1 } If nState = 2 { FileAppend, Process Complete`n`n, * 7Zip_ProcessComplete := 1 Critical, Off } Critical, Off Return 1 } ;End Function Quit(Msg) { MsgBox % Msg ExitApp } #include 7Zip.ahk
Basic Info Example:
/* Function: Example archive info Requires: 7Zip.ahk (include or in Std Library) and AHK_L URL: http://www.autohotkey.com/forum/viewtopic.php?t=69249 */ #NoEnv SetWorkingDir %A_ScriptDir% FileSelectFile,sArcFile, 3,,Open archive..,Archives (*.zip; *.7z; *.bzip2; *.tar; *.iso; *.udf; *.gzip) If !( o7z := 7Zip_Init() ) || !( hArc := 7Zip_OpenArchive(sArcFile) ) ExitApp ; ------- METHOD 1 ----------------------- oFile := 7Zip_FindFirst(hArc,"*.*") ;this will find all files with extensions, for all files use "*" For k,v in oFile ;enumerate all fields of first file sDetails .= k . " = " v . "`n" MsgBox % sDetails While (oFile := 7Zip_FindNext(hArc)) ;enumerate next files { sDetails := "" For k,v in oFile sDetails .= k . " = " v . "`n" MsgBox % sDetails if A_Index > 3 ;Just show 4 files for brevity Break } ; ---------------------------------------- ; ------- METHOD 2 ----------------------- files := "" If 7Zip_FindFirst(hArc, "*.*", 0) ;Notice the last parameter is zero, so just true is returned (no details) Loop files .= 7Zip_GetFileName(hArc) "`n" ;Details can be extracted with individual functions Until !7Zip_FindNext(hArc) Sort files MsgBox % files ; ---------------------------------------- 7Zip_CloseArchive(hArc) #Include 7zip.ahk