neazoi Posted April 12, 2015 Share Posted April 12, 2015 Hello, I have made a small application below expandcollapse popup; ==================================================== ; ============ DataText encoder/decoder ============== ; ==================================================== ; Version: 1.1 ; Language: English ; Author: "sv3ora" ; Website: http://www.qrp.gr/datatext ; ; ---------------------------------------------------------------------------- ; Script Start ; ---------------------------------------------------------------------------- #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ColorConstants.au3> #include <String.au3> #include <FileConstants.au3> #include <Zip.au3> #include <base32.au3> #include <Crypt.au3> _Main() Func RestartScript() If @Compiled = 1 Then Run( FileGetShortName(@ScriptFullPath)) Else Run( FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath)) EndIf Exit EndFunc Func _Main() ; Creates window $WinMain = GUICreate('DataText v1.1 by sv3ora', 570, 320) ; Creates main edit Local $idEditText = GUICtrlCreateEdit('', 5, 5, 560, 280) ; Create the buttons Local $idEncodeButton = GUICtrlCreateButton('Encode', 5, 290, 85, 25) Local $idDecodeButton = GUICtrlCreateButton('Decode', 96, 290, 85, 25) Local $idInfoButton = GUICtrlCreateButton('?', 545, 293, 20, 20) ; Creates the password box with blured and centered input Local $idInputPass = GUICtrlCreateInput('', 187, 290, 100, 24, BitOR($ES_CENTER, $ES_PASSWORD)) ; Pass text label Local $idLabel = GUICtrlCreateLabel(' Password', 191, 294, 91, 17) ; Set the background color of the label Password. GUICtrlSetBkColor($idLabel, $COLOR_WHITE) ; Create the combo to select the crypting algorithm Local $idCombo = GUICtrlCreateCombo("", 291, 290, 88, 20, $CBS_DROPDOWNLIST) GUICtrlSetData($idCombo, "3DES|AES (128bit)|AES (192bit)|AES (256bit)|DES|RC2|RC4", "RC4") ; PROGRESS bar GUICtrlCreateProgress(453, 293, 85, 20) GUICtrlSetData(-1, 0) GUICtrlCreateLabel("Progress:", 387, 295) ; Shows window GUISetState() Local $iAlgorithm = $CALG_RC4 Local $dEncrypted Local $dDecrypted Local $encodedDataZIP While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idCombo ; Check when the combobox is selected and retrieve the correct algorithm. Switch GUICtrlRead($idCombo) ; Read the combobox selection. Case "3DES" $iAlgorithm = $CALG_3DES Case "AES (128bit)" $iAlgorithm = $CALG_AES_128 Case "AES (192bit)" $iAlgorithm = $CALG_AES_192 Case "AES (256bit)" $iAlgorithm = $CALG_AES_256 Case "DES" $iAlgorithm = $CALG_DES Case "RC2" $iAlgorithm = $CALG_RC2 Case "RC4" $iAlgorithm = $CALG_RC4 EndSwitch Case $idEncodeButton ; When you press Encode ;;;;;;;;;;;;;; SELECT FILE TO ENCODE ;;;;;;;;;;;;;;;; ; Create a constant variable in Local scope of the message to display in FileOpenDialog. Local $sMessage = "Select file to encode." ; Display an open dialog to select a file. Local $sFileOpenDialog = FileOpenDialog($sMessage, @DesktopDir & "\", "Images (*.jpg;*.png;*.gif)|All files (*.*)", $FD_FILEMUSTEXIST + $FD_MULTISELECT) If @error Then ; Display the error message. GUICtrlSetData($idEditText, "Error. No file was selected!") RestartScript() ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@DesktopDir) Else ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@DesktopDir) ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog. $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF) EndIf ;;;;;;;;;;;;;; COMPRESS SELECTED FILE ;;;;;;;;;;;;;;;; GUICtrlSetData($idEditText, "Wait for data processing. This may take a while...") ; PROGRESS bar GUICtrlCreateProgress(453, 293, 85, 20) GUICtrlSetData(-1, 10) GUICtrlCreateLabel("Progress:", 387, 295) ;$sFileOpenDialog2 is the tmp.zip file and its path Local $sFileOpenDialog2 = @TempDir&"\tmp.zip" ;compress the file selected ;First check if tmp.zip file exists Local $iFileExists = FileExists($sFileOpenDialog2) Local $Zip ; Display a message of whether the file exists or not. If $iFileExists Then _Zip_AddFile(@TempDir & "\tmp.zip", $sFileOpenDialog) ;add chosen file ($sFileOpenDialog) to the zip archive Else $Zip = _Zip_Create(@TempDir & "\tmp.zip") ;Create The Zip File. Returns a Handle to the zip File _Zip_AddFile(@TempDir & "\tmp.zip", $sFileOpenDialog) ;add chosen file ($sFileOpenDialog) to the zip archive EndIf ;Close the temporary tmp.zip file FileClose($Zip) ; PROGRESS bar GUICtrlCreateProgress(453, 293, 85, 20) GUICtrlSetData(-1, 20) GUICtrlCreateLabel("Progress:", 387, 295) ;;;;;;;;;;;;;; READ COMPRESSED FILE ;;;;;;;;;;;;;;;; ; Open the tmp.zip file for reading and store the handle to a variable. Local $sFileOpen = FileOpen($sFileOpenDialog2, $FO_READ) If $sFileOpen = -1 Then GUICtrlSetData($idEditText, "An error occurred when reading the file.") Return False EndIf ; Read the contents of the tmp.zip file using the handle returned by FileOpen. Local $dataZIP = FileRead($sFileOpen) ; PROGRESS bar GUICtrlCreateProgress(453, 293, 85, 20) GUICtrlSetData(-1, 40) GUICtrlCreateLabel("Progress:", 387, 295) ;Close the temporary tmp.zip file FileClose($sFileOpen) ; Delete the temporary tmp.zip file. FileDelete($sFileOpenDialog2) ; PROGRESS bar GUICtrlCreateProgress(453, 293, 85, 20) GUICtrlSetData(-1, 60) GUICtrlCreateLabel("Progress:", 387, 295) ;If the password box is empty, do not use encryption If GuiCtrlRead($idInputPass) = "" Then ;Encode the contents of the non encrypted variable to zbase32 $encodedDataZIP = _Base32_Encode($dataZIP) ; PROGRESS bar GUICtrlCreateProgress(453, 293, 85, 20) GUICtrlSetData(-1, 80) GUICtrlCreateLabel("Progress:", 387, 295) ;If password box is not empty then use encryption Else ; Calls the encryption. $dEncrypted = _Crypt_EncryptData($dataZIP, GUICtrlRead($idInputPass), $iAlgorithm) ; Encrypt the text with the new cryptographic key. ;Encode the contents of the encrypted variable to zbase32 $encodedDataZIP = _Base32_Encode($dEncrypted) ; PROGRESS bar GUICtrlCreateProgress(453, 293, 85, 20) GUICtrlSetData(-1, 80) GUICtrlCreateLabel("Progress:", 387, 295) EndIf ;;;;;;;;;;;;;; DISPLAY ENCODED DATA ;;;;;;;;;;;;;;;; ; Put encoded data to text box GUICtrlSetData($idEditText, $encodedDataZIP) ; PROGRESS bar GUICtrlCreateProgress(453, 293, 85, 20) GUICtrlSetData(-1, 100) GUICtrlCreateLabel("Progress:", 387, 295) ;wait a bit Sleep(1000) ; PROGRESS bar GUICtrlCreateProgress(453, 293, 85, 20) GUICtrlSetData(-1, 0) GUICtrlCreateLabel("Progress:", 387, 295) Case $idDecodeButton ; When you press Decode ;Read text from input box Local $textTodecodeCaps = GUICtrlRead($idEditText) ;convert all read text to lower case letters Local $textTodecode = StringLower($textTodecodeCaps) ; Friendly message to the text box GUICtrlSetData($idEditText, 'Wait for data processing. This may take a while...') ; PROGRESS bar GUICtrlCreateProgress(453, 293, 85, 20) GUICtrlSetData(-1, 10) GUICtrlCreateLabel("Progress:", 387, 295) ;DECRYPT DECODED DATA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;If the password box is empty, do not use encryption If GuiCtrlRead($idInputPass) = "" Then ;Encode the contents of the non encrypted variable to zbase32 $decodedDataZIP = _Base32_Decode($textTodecode) ; PROGRESS bar GUICtrlCreateProgress(453, 293, 85, 20) GUICtrlSetData(-1, 20) GUICtrlCreateLabel("Progress:", 387, 295) ;If password box is not empty then use decryption Else ;Decode the contents of the variable to zbase32 Local $decodedData = _Base32_Decode($textTodecode) ; Calls the decryption. $decodedDataZIP = _Crypt_DecryptData($decodedData, GUICtrlRead($idInputPass), $iAlgorithm) ; Encrypt the text with the new cryptographic key. ; PROGRESS bar GUICtrlCreateProgress(453, 293, 85, 20) GUICtrlSetData(-1, 20) GUICtrlCreateLabel("Progress:", 387, 295) EndIf ;;;;;;;;;;;;;; WRITE DECODED AND/OR DECRYPTED DATA TO ZIP FILE ;;;;;;;;;;;;;;;; ;$theTMPfile is the tmp zip file and its path Local $theTMPfile = @TempDir&"\tmp2.zip" ; Open the file for writing (append to the end of a file) and store the handle to a variable. Local $rFileOpen = FileOpen($theTMPfile, $FO_OVERWRITE) If $rFileOpen = -1 Then GUICtrlSetData($idEditText, "An error occurred when reading the file.") Return False EndIf ; PROGRESS bar GUICtrlCreateProgress(453, 293, 85, 20) GUICtrlSetData(-1, 40) GUICtrlCreateLabel("Progress:", 387, 295) ; Write data to the file using the handle returned by FileOpen. FileWrite($rFileOpen, $decodedDataZIP) ; Close the handle returned by FileOpen. FileClose($rFileOpen) ; PROGRESS bar GUICtrlCreateProgress(453, 293, 85, 20) GUICtrlSetData(-1, 60) GUICtrlCreateLabel("Progress:", 387, 295) ;;;;;;;;;;;;;; UNZIP THE ZIP FILE ;;;;;;;;;;;;;;;; _Zip_UnzipAll($theTMPfile, @ScriptDir) ; PROGRESS bar GUICtrlCreateProgress(453, 293, 85, 20) GUICtrlSetData(-1, 80) GUICtrlCreateLabel("Progress:", 387, 295) ; Delete the temporary tmp.zip file. FileDelete($theTMPfile) ; Put initial encoded data to text box GUICtrlSetData($idEditText, $textTodecode) ; PROGRESS bar GUICtrlCreateProgress(453, 293, 85, 20) GUICtrlSetData(-1, 100) GUICtrlCreateLabel("Progress:", 387, 295) ;wait a bit Sleep(1000) ; PROGRESS bar GUICtrlCreateProgress(453, 293, 85, 20) GUICtrlSetData(-1, 0) GUICtrlCreateLabel("Progress:", 387, 295) Case $idInfoButton ;When you press ? ; Info message to the text box GUICtrlSetData($idEditText, "DataText by sv3ora."&@crlf&"Conversion of file to text and text to file."&@crlf&@crlf&"This program can be used to transfer data"&@crlf&"through any radio amateur digital mode (including CW)"&@crlf&"that supports text-only transmission"&@crlf&@crlf&"To encode a file:"&@crlf&"1. Click 'Encode' to select the file to encode."&@crlf&"2. Select all encoded text (right click) and copy it."&@crlf&"3. Paste this text to your favorite sending program."&@crlf&"If you want to password protect your file, enter a password and select the"&@crlf&"encryption algorithm from the drop down list, prior to clicking the encode button."&@crlf&@crlf&"To decode a text:"&@crlf&"1. Copy the text to decode from your favorite receiving"&@crlf&" program and paste it into this text box."&@crlf&"2. Click 'Decode' to decode this text."&@crlf&"3. The decoded file will be placed at the same directory"&@crlf&" as the DataText program."&@crlf&"If the received data has been password protected, then you have to enter the"&@crlf&"password and select the encryption algorithm from the drop down list,"&@crlf&"prior to clicking the decode button."&@crlf&@crlf&"More info about DataText at: http://www.qrp.gr/datatext"&@crlf&"Comments and suggestions at: sv3ora@qrp.gr") EndSwitch WEnd EndFunc ;==>_Main The problem is that the _Zip_Addfile() does not work on win2k. It works ok on winxp and 7. On win2k the zip file is created and nothing is added into it. The zip.au3 include is below: expandcollapse popup;#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <array.au3> $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") ;added this b/c there is a bug in the zip.au3 and we want to ignore the com error basically... Func _ErrFunc($oError) ; Do anything here. ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _ "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ "err.description is: " & @TAB & $oError.description & @CRLF & _ "err.source is: " & @TAB & $oError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF) EndFunc ;==>_ErrFunc ; ------------------------------------------------------------------------------ ; ; AutoIt Version: 3.2 ; Language: English ; Description: ZIP Functions. ; Author: torels_ ; ; ------------------------------------------------------------------------------ ;~ If UBound($CMDLine) > 1 Then ;~ If $CMDLine[1] <> "" Then _Zip_VirtualZipOpen() ;~ EndIf ;=============================================================================== ; ; Function Name: _Zip_Create() ; Description: Create Empty ZIP file. ; Parameter(s): $hFilename - Complete path to zip file that will be created ; Requirement(s): none. ; Return Value(s): Returns the Zip file path (to be used as a handle - even though it's not necessary) ; Author(s): torels_ ; ;=============================================================================== Func _Zip_Create($hFilename) $hFp = FileOpen($hFilename, 26) $sString = Chr(80) & Chr(75) & Chr(5) & Chr(6) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) FileWrite($hFp, $sString) If @error Then Return SetError(1,0,0) FileClose($hFp) While Not FileExists($hFilename) Sleep(10) Wend Return $hFilename EndFunc ;==>_Zip_Create ;=============================================================================== ; ; Function Name: _Zip_AddFile() ; Description: Add a file to a ZIP Archieve. ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; $hFile2Add - Complete path to the file that will be added ; $flag = 1 ; - 0 ProgressBox ; - 1 no progress box ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1~3 ; @error = 1 no Zip file ; @error = 2 no dll ; @error = 3 dll isn't registered ; On Failure - Returns False ; Author(s): torels_ ; Notes: The return values will be given once the compressing process is ultimated... it takes some time with big files ; ;=============================================================================== Func _Zip_AddFile($hZipFile, $hFile2Add, $flag = 1) Local $DLLChk = _Zip_DllChk() Local $files = _Zip_Count($hZipFile) If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0);no dll If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file $oApp = ObjCreate("Shell.Application") $copy = $oApp.NameSpace($hZipFile).CopyHere($hFile2Add) While 1 If $flag = 1 then _Hide() If _Zip_Count($hZipFile) = ($files+1) Then ExitLoop Sleep(10) WEnd Return SetError(0,0,1) EndFunc ;==>_Zip_AddFile ;=============================================================================== ; ; Function Name: _Zip_AddFolder() ; Description: Add a folder to a ZIP Archieve. ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; $hFolder - Complete path to the folder that will be added (possibly including "\" at the end) ; $flag = 1 ; - 1 no progress box ; - 0 progress box ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1~3 ; @error = 1 no Zip file ; @error = 2 no dll ; @error = 3 dll isn't registered ; Author(s): torels_ ; Notes: The return values will be given once the compressing process is ultimated... it takes some time with big files ; ;=============================================================================== Func _Zip_AddFolder($hZipFile, $hFolder, $flag = 1) Local $DLLChk = _Zip_DllChk() If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0);no dll If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file If StringRight($hFolder, 1) <> "\" Then $hFolder &= "\" $files = _Zip_Count($hZipFile) $oApp = ObjCreate("Shell.Application") $oCopy = $oApp.NameSpace($hZipFile).CopyHere($oApp.Namespace($hFolder)) While 1 If $flag = 1 then _Hide() If _Zip_Count($hZipFile) = ($files+1) Then ExitLoop Sleep(10) WEnd Return SetError(0,0,1) EndFunc ;==>_Zip_AddFolder ;=============================================================================== ; ; Function Name: _Zip_AddFolderContents() ; Description: Add a folder to a ZIP Archieve. ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; $hFolder - Complete path to the folder that will be added (possibly including "\" at the end) ; $flag = 1 ; - 1 no progress box ; - 0 progress box ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1~3 ; @error = 1 no Zip file ; @error = 2 no dll ; @error = 3 dll isn't registered ; Author(s): torels_ ; Notes: The return values will be given once the compressing process is ultimated... it takes some time with big files ; ;=============================================================================== Func _Zip_AddFolderContents($hZipFile, $hFolder, $flag = 1) Local $DLLChk = _Zip_DllChk() If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0);no dll If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file If StringRight($hFolder, 1) <> "\" Then $hFolder &= "\" $files = _Zip_Count($hZipFile) $oApp = ObjCreate("Shell.Application") $oFolder = $oApp.NameSpace($hFolder) $oCopy = $oApp.NameSpace($hZipFile).CopyHere($oFolder.Items) $oFC = $oApp.NameSpace($hFolder).items.count While 1 If $flag = 1 then _Hide() Else WinActivate("[CLASS:#32770; TITLE:Compressing]") EndIf If _Zip_Count($hZipFile) = ($files+$oFC) Then ExitLoop Sleep(10) WEnd Return SetError(0,0,1) EndFunc ;==>_Zip_AddFolderContents ;=============================================================================== ; ; Function Name: _Zip_Delete() ; Description: Delete a file from a ZIP Archive. ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; $hFolder - Complete path to the folder that will be added (possibly including "\" at the end) ; $flag = 1 ; - 1 no progress box ; - 0 progress box ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1~3 ; @error = 1 no Zip file ; @error = 2 no dll ; @error = 3 dll isn't registered ; Author(s): torels_ ; Notes: none ; ;=============================================================================== Func _Zip_Delete($hZipFile, $hFilename, $flag = 1) Local $DLLChk = _Zip_DllChk() If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0);no dll If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file $list = _Zip_List($hZipFile) $dir = @TempDir & "\tmp" & Floor(Random(0,100)) For $i = 1 to $list[0] If $list[$i] <> $hFilename Then _Zip_Unzip($hZipFile,$list[$i],$dir, $flag) Next FileDelete($hZipFile) _Zip_Create($hZipFile) _Zip_AddFolderContents($hZipFile, $dir, $flag) DirRemove($dir) EndFunc ;=============================================================================== ; ; Function Name: _Zip_UnzipAll() ; Description: Extract all files contained in a ZIP Archieve. ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; $hDestPath - Complete path to where the files will be extracted ; $flag = 1 ; - 1 no progress box ; - 0 progress box ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1~3 ; @error = 1 no Zip file ; @error = 2 no dll ; @error = 3 dll isn't registered ; Author(s): torels_ ; Notes: The return values will be given once the extracting process is ultimated... it takes some time with big files ; ;=============================================================================== Func _Zip_UnzipAll($hZipFile, $hDestPath, $flag = 1) Local $DLLChk = _Zip_DllChk() If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0);no dll If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path If Not FileExists($hZipFile) Then Return SetError(2, 0, 0) ;no zip file If Not FileExists($hDestPath) Then DirCreate($hDestPath) Local $aArray[1] $oApp = ObjCreate("Shell.Application") $oApp.Namespace($hDestPath).CopyHere($oApp.Namespace($hZipFile).Items) For $item In $oApp.Namespace($hZipFile).Items _ArrayAdd($aArray, $item) Next While 1 If $flag = 1 then _Hide() Else WinActivate("[CLASS:#32770; TITLE:Copying]") EndIf If FileExists($hDestPath & "\" & $aArray[UBound($aArray) - 1]) Then Return SetError(0, 0, 1) ExitLoop EndIf Sleep(500) WEnd EndFunc ;==>_Zip_UnzipAll ;=============================================================================== ; ; Function Name: _Zip_Unzip() ; Description: Extract a single file contained in a ZIP Archieve. ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; $hFilename - Name of the element in the zip archive ex. "hello_world.txt" ; $hDestPath - Complete path to where the files will be extracted ; $flag = 1 ; - 1 no progress box ; - 0 progress box ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1~3 ; @error = 1 no Zip file ; @error = 2 no dll ; @error = 3 dll isn't registered ; Author(s): torels_ ; Notes: The return values will be given once the extracting process is ultimated... it takes some time with big files ; ;=============================================================================== Func _Zip_Unzip($hZipFile, $hFilename, $hDestPath, $flag = 1) Local $DLLChk = _Zip_DllChk() If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0) ;no dll If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file If Not FileExists($hDestPath) Then DirCreate($hDestPath) $oApp = ObjCreate("Shell.Application") $hFolderitem = $oApp.NameSpace($hZipFile).Parsename($hFilename) $oApp.NameSpace($hDestPath).Copyhere($hFolderitem) While 1 If $flag = 1 then _Hide() If FileExists($hDestPath & "\" & $hFilename) Then return SetError(0, 0, 1) ExitLoop EndIf Sleep(500) WEnd EndFunc ;==>_Zip_Unzip ;=============================================================================== ; ; Function Name: _Zip_Count() ; Description: Count files contained in a ZIP Archieve. ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1~3 ; @error = 1 no Zip file ; @error = 2 no dll ; @error = 3 dll isn't registered ; Author(s): torels_ ; ;=============================================================================== Func _Zip_Count($hZipFile) Local $DLLChk = _Zip_DllChk() If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0) ;no dll If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file $items = _Zip_List($hZipFile) Return UBound($items) - 1 EndFunc ;==>_Zip_Count ;=============================================================================== ; ; Function Name: _Zip_CountAll() ; Description: Count All files contained in a ZIP Archive (including Sub Directories) ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1~3 ; @error = 1 no Zip file ; @error = 2 no dll ; @error = 3 dll isn't registered ; Author(s): torels_, Smashly ; ;=============================================================================== Func _Zip_CountAll($hZipFile) Local $DLLChk = _Zip_DllChk() If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0) ;no dll If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file $oApp = ObjCreate("Shell.Application") $oDir = $oApp.NameSpace(StringLeft($hZipFile, StringInStr($hZipFile, "\", 0, -1))) $sZipInf = $oDir.GetDetailsOf($oDir.ParseName(StringTrimLeft($hZipFile, StringInStr($hZipFile, "\", 0, -1))), -1) Return StringRight($sZipInf, StringLen($sZipInf) - StringInStr($sZipInf, ": ") - 1) EndFunc ;=============================================================================== ; ; Function Name: _Zip_List() ; Description: Returns an Array containing of all the files contained in a ZIP Archieve. ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1~3 ; @error = 1 no Zip file ; @error = 2 no dll ; @error = 3 dll isn't registered ; Author(s): torels_ ; ;=============================================================================== Func _Zip_List($hZipFile) local $aArray[1] Local $DLLChk = _Zip_DllChk() If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0) ;no dll If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file $oApp = ObjCreate("Shell.Application") $zipnamespace = $oApp.Namespace($hZipFile) $hList = $zipnamespace.Items For $item in $hList _ArrayAdd($aArray,$item.name) Next $aArray[0] = UBound($aArray) - 1 Return $aArray EndFunc ;==>_Zip_List ;=============================================================================== ; ; Function Name: _Zip_Search() ; Description: Search files in a ZIP Archive. ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; $sSearchString - name of the file to be searched ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1 (no file found) ; Author(s): torels_ ; Notes: none ; ;=============================================================================== Func _Zip_Search($hZipFile, $sSearchString) local $aArray Local $DLLChk = _Zip_DllChk() If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0) ;no dll If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file $list = _Zip_List($hZipFile) for $i = 0 to UBound($list) - 1 if StringInStr($list[$i],$sSearchstring) > 0 Then _ArrayAdd($aArray, $list[$i]) EndIf Next if UBound($aArray) - 1 = 0 Then Return SetError(1,0,0) Else Return $aArray EndIf EndFunc ;==> _Zip_Search ;=============================================================================== ; ; Function Name: _Zip_SearchInFile() ; Description: Search files in a ZIP Archive's File. ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; $sSearchString - name of the file to be searched ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1 (no file found) ; Author(s): torels_ ; Notes: none ; ;=============================================================================== Func _Zip_SearchInFile($hZipFile, $sSearchString) local $aArray $list = _Zip_List($hZipFile) for $i = 1 to UBound($list) - 1 _Zip_Unzip($hZipFile, $list[$i], @TempDir & "\tmp_zip.file") $read = FileRead(@TempDir & "\tmp_zip.file") if StringInStr($read,$sSearchstring) > 0 Then _ArrayAdd($aArray, $list[$i]) EndIf Next if UBound($aArray) - 1 = 0 Then Return SetError(1,0,1) Else Return $aArray EndIf EndFunc ;==> _Zip_Search ;=============================================================================== ; ; Function Name: _Zip_VirtualZipCreate() ; Description: Create a Virtual Zip. ; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant) ; $sPath - Path to where create the Virtual Zip ; Requirement(s): none. ; Return Value(s): On Success - List of Created Files ; On Failure - sets @error 1~3 ; @error = 1 no Zip file ; @error = 2 no dll ; @error = 3 dll isn't registered ; Author(s): torels_ ; Notes: none ; ;=============================================================================== Func _Zip_VirtualZipCreate($hZipFile, $sPath) $List = _Zip_List($hZipFile) If @error Then Return SetError(@error,0,0) If Not FileExists($sPath) Then DirCreate($sPath) If StringRight($sPath, 1) = "\" Then $sPath = StringLeft($sPath, StringLen($sPath) -1) For $i = 1 to $List[0] If Not @Compiled Then $Cmd = @AutoItExe $params = '"' & @ScriptFullPath & '" ' & '"' & $hZipFile & "," & $List[$i] & '"' Else $Cmd = @ScriptFullPath $Params = '"' & $hZipFile & "," & $List[$i] & '"' EndIf FileCreateShortcut($Cmd, $sPath & "\" & $List[$i], -1,$Params, "Virtual Zipped File", _GetIcon($List[$i], 0), "", _GetIcon($List[$i], 1)) Next $List = _ArrayInsert($List, 1, $sPath) Return $List EndFunc ;=============================================================================== ; ; Function Name: _Zip_VirtualZipOpen() ; Description: Open A File in a Virtual Zip, Internal Function. ; Parameter(s): none. ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - sets @error 1~3 ; @error = 1 no Zip file ; @error = 2 no dll ; @error = 3 dll isn't registered ; Author(s): torels_ ; Notes: none ; ;=============================================================================== Func _Zip_VirtualZipOpen() $ZipSplit = StringSplit($CMDLine[1], ",") $ZipName = $ZipSplit[1] $ZipFile = $ZipSplit[2] _Zip_Unzip($ZipName, $ZipFile, @TempDir & "\", 4+16) ;no progress + yes to all If @error Then Return SetError(@error,0,0) ShellExecute(@TempDir & "\" & $ZipFile) EndFunc ;=============================================================================== ; ; Function Name: _Zip_VirtualZipOpen() ; Description: Delete a Virtual Zip. ; Parameter(s): none. ; Requirement(s): none. ; Return Value(s): On Success - 0 ; On Failure - none. ; Author(s): torels_ ; Notes: none ; ;=============================================================================== Func _Zip_VirtualZipDelete($aVirtualZipHandle) For $i = 2 to UBound($aVirtualZipHandle)-1 If FileExists($aVirtualZipHandle[1] & "\" & $aVirtualZipHandle[$i]) Then FileDelete($aVirtualZipHandle[1] & "\" & $aVirtualZipHandle[$i]) Next Return 0 EndFunc ;=============================================================================== ; ; Function Name: _Zip_DllChk() ; Description: Internal error handler. ; Parameter(s): none. ; Requirement(s): none. ; Return Value(s): Failure - @extended = 1 ; Author(s): smashley ; ;=============================================================================== Func _Zip_DllChk() If Not FileExists(@SystemDir & "\zipfldr.dll") Then Return 2 If Not RegRead("HKEY_CLASSES_ROOT\CLSID\{E88DCCE0-B7B3-11d1-A9F0-00AA0060FA31}", "") Then Return 3 Return 0 EndFunc ;==>_Zip_DllChk ;=============================================================================== ; ; Function Name: _GetIcon() ; Description: Internal Function. ; Parameter(s): $file - File form which to retrieve the icon ; $ReturnType - IconFile or IconID ; Requirement(s): none. ; Return Value(s): Icon Path/ID ; Author(s): torels_ ; ;=============================================================================== Func _GetIcon($file, $ReturnType = 0) $FileType = StringSplit($file, ".") $FileType = $FileType[UBound($FileType)-1] $FileParam = RegRead("HKEY_CLASSES_ROOT\." & $FileType, "") $DefaultIcon = RegRead("HKEY_CLASSES_ROOT\" & $FileParam & "\DefaultIcon", "") If Not @error Then $IconSplit = StringSplit($DefaultIcon, ",") ReDim $IconSplit[3] $Iconfile = $IconSplit[1] $IconID = $IconSplit[2] Else $Iconfile = @SystemDir & "\shell32.dll" $IconID = -219 EndIf If $ReturnType = 0 Then Return $Iconfile Else Return $IconID EndIf EndFunc ;=============================================================================== ; ; Function Name: _IsFullPath() ; Description: Internal Function. ; Parameter(s): $path - a zip path ; Requirement(s): none. ; Return Value(s): success - True. ; failure - False. ; Author(s): torels_ ; ;=============================================================================== Func _IsFullPath($path) if StringInStr($path,":\") then Return True Else Return False EndIf Endfunc ;=============================================================================== ; ; Function Name: _Hide() ; Description: Internal Function. ; Parameter(s): none ; Requirement(s): none. ; Return Value(s): none. ; Author(s): torels_ ; ;=============================================================================== Func _Hide() If ControlGetHandle("[CLASS:#32770]", "", "[CLASS:SysAnimate32; INSTANCE:1]") <> "" And WinGetState("[CLASS:#32770]") <> @SW_HIDE Then ;The Window Exists $hWnd = WinGetHandle("[CLASS:#32770]") WinSetState($hWnd, "", @SW_HIDE) EndIf EndFunc Link to comment Share on other sites More sharing options...
Kyan Posted April 12, 2015 Share Posted April 12, 2015 http://www.petri.com/enable_compressed_folder_in_w2k.htm  The Compressed Folder feature that exists in Microsoft Plus! 98, Microsoft Windows Millennium Edition and Microsoft Windows XP was not included in the Microsoft Windows 2000 family products. Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
neazoi Posted April 13, 2015 Author Share Posted April 13, 2015 (edited) http://www.petri.com/enable_compressed_folder_in_w2k.htm Thank you for the useful information! Is there any way I can do it without having to install this fix or without uzing an external program (eg. 7zip)? Also, I cannot find this patch for windows ME that is required. Please let me know what to do Edited April 13, 2015 by neazoi Link to comment Share on other sites More sharing options...
Kyan Posted April 13, 2015 Share Posted April 13, 2015 If I were you, I would incorporate zipfldr.dll into your script (use UPX to compress the dll) using MemoryDll.au3 Be advised it may require other .dll's (exe/dll's have dependencies), so it's better to take the one compatible with win2k and merge it into your script Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
neazoi Posted April 13, 2015 Author Share Posted April 13, 2015 http://www.petri.com/enable_compressed_folder_in_w2k.htm I have finally installed the patch. Now I can do right click > send to > compressed folder in windows 2000. However, when I try to create the zip file and add a file into it, in my application, It now asks to replace the already empty created file with the image file which I am trying to zip. Link to comment Share on other sites More sharing options...
neazoi Posted April 13, 2015 Author Share Posted April 13, 2015 If I were you, I would incorporate zipfldr.dll into your script (use UPX to compress the dll) using MemoryDll.au3 Be advised it may require other .dll's (exe/dll's have dependencies), so it's better to take the one compatible with win2k and merge it into your script This is useful, but I have no idea how to call the functions of the dll. in the zip.au3, in the _Zip_Addfile(). I somehow have to replace Objcreate, Namespace and Copyhere, but I do not how. Any ideas? Link to comment Share on other sites More sharing options...
Kyan Posted April 14, 2015 Share Posted April 14, 2015 You just read MemoryDll.au3 instructions about how to include an .dll into your script. Can you upload the zipfldr.dll of win2k to a host? (like zippyshare.com) Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better 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