Ward Posted May 24, 2011 Share Posted May 24, 2011 (edited) To use zLib in AutoIt, the easiest way is download the DLL, and then just use it by DllCall, or warp it by my But now I convert zLib to machine code version UDF, because "just for fun", or because I can.There is another good reason: to minimize the UDF size (because there are some functions I don't need in the DLL file).The best thing of this library is that it can compress/decompress the gzip format.So this is also a "GZIP UDF" in pure script.Example:expandcollapse popup; ----------------------------------------------------------------------------- ; Zlib Compression Library (Deflate/Inflate) Machine Code UDF Example ; Purpose: Provide The Machine Code Version of Zlib Library In AutoIt ; Author: Ward ; Zlib Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler ; ----------------------------------------------------------------------------- #Include "ZLIB.au3" ; Test _ZLIB_Compress And _ZLIB_Uncompress Dim $Original = BinaryFileRead(@AutoItExe) Dim $Compressed = _ZLIB_Compress($Original, 9) Dim $Decompressed = _ZLIB_Uncompress($Compressed) Dim $Result = 'Original Size: ' & BinaryLen($Original) & @CRLF $Result &= 'Compressed Size: ' & BinaryLen($Compressed) & @CRLF $Result &= 'Decompress Succeed: ' & ($Decompressed = $Original) MsgBox(0,'Deflate/Inflate Test', $Result) ; Test _ZLIB_GZCompress And _ZLIB_GZUncompress Dim $Original = BinaryFileRead(@AutoItExe) Dim $Compressed = _ZLIB_GZCompress($Original, 9) Dim $Decompressed = _ZLIB_GZUncompress($Compressed) Dim $Result = 'Original Size: ' & BinaryLen($Original) & @CRLF $Result &= 'Compressed Size: ' & BinaryLen($Compressed) & @CRLF $Result &= 'Decompress Succeed: ' & ($Decompressed = $Original) MsgBox(0,'Gzip Test', $Result) ; Test _ZLIB_FileCompress And _ZLIB_FileUncompress Dim $OriginalPath = @AutoItExe Dim $CompressedPath = @TempDir & "\test.z" Dim $DecompressedPath = @TempDir & "\test.unz" _ZLIB_FileCompress($OriginalPath, $CompressedPath, 9) _ZLIB_FileUncompress($CompressedPath, $DecompressedPath) Dim $Result = 'Original Size: ' & FileGetSize($OriginalPath) & @CRLF $Result &= 'Compressed Size: ' & FileGetSize($CompressedPath) & @CRLF $Result &= 'Decompress Succeed: ' & (BinaryFileRead($DecompressedPath) = BinaryFileRead($OriginalPath)) FileDelete($CompressedPath) FileDelete($DecompressedPath) MsgBox(0,'Deflate/Inflate File Test', $Result) ; Test _ZLIB_GZFileCompress And _ZLIB_GZFileUncompress Dim $OriginalPath = @AutoItExe Dim $CompressedPath = @TempDir & "\test.gz" Dim $DecompressedPath = @TempDir & "\test.ungz" _ZLIB_GZFileCompress($OriginalPath, $CompressedPath, 9) _ZLIB_GZFileUncompress($CompressedPath, $DecompressedPath) Dim $Result = 'Original Size: ' & FileGetSize($OriginalPath) & @CRLF $Result &= 'Compressed Size: ' & FileGetSize($CompressedPath) & @CRLF $Result &= 'Decompress Succeed: ' & (BinaryFileRead($DecompressedPath) = BinaryFileRead($OriginalPath)) FileDelete($CompressedPath) FileDelete($DecompressedPath) MsgBox(0,'Gzip File Test', $Result) Exit Func BinaryFileRead($Path) Local $File = FileOpen($Path, 16) Local $Data = FileRead($File) FileClose($File) Return $Data EndFuncFor other compression method, see my "ZLIB.zip Edited May 24, 2011 by Ward ducln456789 1 新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了。 Link to comment Share on other sites More sharing options...
Digisoul Posted May 24, 2011 Share Posted May 24, 2011 Awesome work Ward, 5 stars from me. 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
Zedna Posted May 24, 2011 Share Posted May 24, 2011 Very nice! Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
tip Posted May 28, 2011 Share Posted May 28, 2011 Thanks Ward. This is great... [center]MsgBox_Tipped: Eye candy msgboxes/inputboxes/loginboxes. | CreateBlankBox: Semi-transparent layers with borders and rounded corners.[/center] Link to comment Share on other sites More sharing options...
joakim Posted June 12, 2011 Share Posted June 12, 2011 Great work Ward! I found it really interesting to be able to deflate and/or inflate in raw mode, ie without header and footer. Just put $Level = -15 (windowBits) and you're able to compress/uncompress in raw mode. Thanks once again. Joakim Link to comment Share on other sites More sharing options...
ynbIpb Posted November 5, 2012 Share Posted November 5, 2012 (edited) [deleted] Edited November 5, 2012 by ynbIpb Link to comment Share on other sites More sharing options...
legend Posted December 8, 2012 Share Posted December 8, 2012 I tried to do this, but didn't work: #Include "ZLIB.au3" $Path = (@scriptdir & "test.exe") ; Test _ZLIB_Compress And _ZLIB_Uncompress Dim $Original = BinaryFileRead(@ScriptDir & "test.exe") Dim $Compressed = _ZLIB_Compress($Original, 9) Func BinaryFileRead($Path) Local $File = FileOpen($Path, 16) Local $Data = FileRead($File) FileClose($File) Return $Data EndFunc Link to comment Share on other sites More sharing options...
water Posted December 8, 2012 Share Posted December 8, 2012 Legend, I know nothing about this UDF. But if you want to get help from anyone you need to be more specific. "Doesn't work" isn't. Do you get any error messages? Is @error set? Does the script crash? ... My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
legend Posted December 9, 2012 Share Posted December 9, 2012 I don't get any errors, the script runs, but doesen't compress test.exe Link to comment Share on other sites More sharing options...
legend Posted December 13, 2012 Share Posted December 13, 2012 no one ? Link to comment Share on other sites More sharing options...
wraithdu Posted December 13, 2012 Share Posted December 13, 2012 If you're referring specifically to your test script... well, what are you doing with $Compressed? As far as I can see you're doing nothing with it. Your script and the functions don't compress any data in place, so what do you expect the end result to be? Link to comment Share on other sites More sharing options...
NewPlaza Posted August 12, 2013 Share Posted August 12, 2013 (edited) I tried to do this, but didn't work: #Include "ZLIB.au3" $Path = (@scriptdir & "test.exe") ; Test _ZLIB_Compress And _ZLIB_Uncompress Dim $Original = BinaryFileRead(@ScriptDir & "test.exe") Dim $Compressed = _ZLIB_Compress($Original, 9) Func BinaryFileRead($Path) Local $File = FileOpen($Path, 16) Local $Data = FileRead($File) FileClose($File) Return $Data EndFunc I know this topic is VERY old but I couldn't resist. Also, this may help..... ;$Path = (@scriptdir & "test.exe") $Path = (@scriptdir & "\test.exe"); * Don't forget the backslash.. ;Dim $Original = BinaryFileRead(@ScriptDir & "test.exe") Dim $Original = BinaryFileRead($Path) Edited August 12, 2013 by NewPlaza Link to comment Share on other sites More sharing options...
lionfaggot Posted February 9, 2014 Share Posted February 9, 2014 (edited) will this work to decode a gzip encoded http body? and if so how would i do that exactly? Edited February 9, 2014 by lionfaggot Link to comment Share on other sites More sharing options...
lionfaggot Posted February 9, 2014 Share Posted February 9, 2014 well the good news is i learned a lot today, i changed one of my headers to: "Accept-Encoding: deflate" and it automatically deflates for me. i also know a lot more about certain subjects in general. VERY PRODUCTIVE DAY! Jos i owe you one man. a friend is paying me for my current project lol - you saved me some troubles Link to comment Share on other sites More sharing options...
Developers Jos Posted February 9, 2014 Developers Share Posted February 9, 2014 well the good news is i learned a lot today, i changed one of my headers to: "Accept-Encoding: deflate" and it automatically deflates for me. i also know a lot more about certain subjects in general. VERY PRODUCTIVE DAY! Jos i owe you one man. a friend is paying me for my current project lol - you saved me some troubles Good for you SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Vĩ Kha Blog Posted May 27, 2016 Share Posted May 27, 2016 I can't download it. Can you help me ? Link to comment Share on other sites More sharing options...
argumentum Posted May 28, 2016 Share Posted May 28, 2016 On 5/27/2016 at 10:57 PM, Vĩ Kha Blog said: I can't download it. Can you help me ? attached below. ZLIB.zip oo0oo and ss26 1 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Vĩ Kha Blog Posted May 28, 2016 Share Posted May 28, 2016 12 hours ago, argumentum said: attached below. ZLIB.zip I work, I have downloaded, thank you very much argumentum 1 Link to comment Share on other sites More sharing options...
Frescard Posted September 21, 2018 Share Posted September 21, 2018 Does this still work? I'm using the code from the post 2 above me, and am trying the default example (under Win10), but only get an error code... #Include "ZLIB.au3" ; Test _ZLIB_Compress And _ZLIB_Uncompress Dim $Original = BinaryFileRead(@AutoItExe) Dim $Compressed = _ZLIB_Compress($Original, 9) Dim $Decompressed = _ZLIB_Uncompress($Compressed) Dim $Result = 'Original Size: ' & BinaryLen($Original) & @CRLF $Result &= 'Compressed Size: ' & BinaryLen($Compressed) & @CRLF $Result &= 'Decompress Succeed: ' & ($Decompressed = $Original) MsgBox(0,'Deflate/Inflate Test', $Result) Exit Func BinaryFileRead($Path) Local $File = FileOpen($Path, 16) Local $Data = FileRead($File) FileClose($File) Return $Data EndFunc This comes up after Autoit tries to execute the _ZLIB_Compress function: !>14:11:15 AutoIt3.exe ended.rc:-1073741819 Link to comment Share on other sites More sharing options...
moimon Posted September 22, 2018 Share Posted September 22, 2018 9 hours ago, Frescard said: Does this still work? I'm using the code from the post 2 above me, and am trying the default example (under Win10), but only get an error code... This comes up after Autoit tries to execute the _ZLIB_Compress function: !>14:11:15 AutoIt3.exe ended.rc:-1073741819 Add #AutoIt3Wrapper_UseX64 = no in first line ^^ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now