guinness Posted May 16, 2011 Share Posted May 16, 2011 (edited) The UDF creates a file which contains binary data of files that are added to the BinaryBin file (using the provided functions.) I decided to create this UDF because I was internally updating applications using 7-Zip (FileInstall'ed) and then extracting the ZIP file which was downloaded from the website. Despite this being effective I wanted to create a UDF in which I could import files into a file and then extract using a single function & without the need for an external application.Even though I decided to create this UDF myself, it should be pointed out that I did search the Forum to see if anything was currently available and came across >AUBinary.au3, though the function syntax's are very different and I believe my version is slightly faster.Any suggestions post below. Thanks.UDF:expandcollapse popup#include-once ; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 ; #INDEX# ======================================================================================================================= ; Title .........: _BinaryBin ; AutoIt Version : v3.3.10.0 or higher ; Language ......: English ; Description ...: Creates a bin file to store files that can then be extracted using native AutoIt code. ; Note ..........: ; Author(s) .....: guinness ; Remarks .......: Thanks to SmOke_N for hints about the DIR command and Malkey for the SRE's. [http://www.autoitscript.com/forum/topic/95580-a-question-regarding-pathsplit/page__view__findpost__p__687288]. ; =============================================================================================================================== ; #INCLUDES# ==================================================================================================================== #include <Crypt.au3> #include <File.au3> #include <WinAPI.au3> ; #GLOBAL VARIABLES# ============================================================================================================ Global Const $BINARYBIN_GUID = 'D74855F2-E356-11E3-8EDA-00A70707A45E' Global Enum $BINARYBIN_FILENAME, $BINARYBIN_FILEPATH, $BINARYBIN_HWND, $BINARYBIN_ID, $BINARYBIN_MAX Global Enum $BINARYBIN_ERROR_NONE, $BINARYBIN_ERROR_FATAL, $BINARYBIN_ERROR_INVALIDBIN, $BINARYBIN_ERROR_INVALIDFILENAME, $BINARYBIN_ERROR_INVALIDFOLDER ; #CURRENT# ===================================================================================================================== ; _BinaryBin: Create a new binary bin object by opening a new or previous binary file. ; _BinaryBin_Add: Add a file to a binary bin. ; _BinaryBin_AddFolder: Add a folder to a binary bin file. This is recursive i.e. it will search sub-folders too. ; _BinaryBin_Close: Close a binary bin file. ; _BinaryBin_Decrypt: Decrypt a binary bin file. ; _BinaryBin_Encrypt: Encrypt a binary bin file. ; _BinaryBin_Extract: Extract a binary bin file to a specified folder/path. ; _BinaryBin_GetFileCount: Retrieve the file count in a binary bin file. ; _BinaryBin_GetFiles: Retrieve the list of files in a binary bin file. ; _BinaryBin_GetFolders: Retrieve the list of folders in a binary bin file. ; _BinaryBin_GetSize: Retrieve the filesize of a BinaryBin file. ; _BinaryBin_GetFilePath: Rerieve the filepath of a handle returned by _BinaryBin. ; _BinaryBin_IsEncrypted: Check if a binary bin file is encrypted. ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ; See below ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name ..........: _BinaryBin ; Description ...: Create a new binary bin object by opening a new or previous binary file. ; Syntax ........: _BinaryBin($sFilePath[, $bOverwrite = False]) ; Parameters ....: $sFilePath - Filepath of a new or previous binary bin file. ; $bOverwrite - [optional] Overwrite the binary bin. Default is False. ; Return values .: Handle to be passed to relevant functions. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _BinaryBin($sFilePath, $bOverwrite = False) Local $aBinaryBin[$BINARYBIN_MAX] $aBinaryBin[$BINARYBIN_FILENAME] = __BinaryBin_GetFileName($sFilePath) $aBinaryBin[$BINARYBIN_FILEPATH] = $sFilePath ; $CREATE_ALWAYS = 2 $aBinaryBin[$BINARYBIN_HWND] = _WinAPI_CreateFile($sFilePath, ($bOverwrite ? $CREATE_NEW : $CREATE_ALWAYS), BitOR($FILE_SHARE_WRITE, $FILE_SHARE_DELETE), 0, 0, 0) If $aBinaryBin[$BINARYBIN_HWND] > 0 Then $aBinaryBin[$BINARYBIN_ID] = $BINARYBIN_GUID Return $aBinaryBin EndFunc ;==>_BinaryBin ; #FUNCTION# ==================================================================================================================== ; Name ..........: _BinaryBin_Add ; Description ...: Add a file to a binary bin. ; Syntax ........: _BinaryBin_Add(ByRef $aBinaryBin, $sFilePath[, $bOverwrite = False]) ; Parameters ....: $aBinaryBin - [in/out and const] Handle created by _BinaryBin. ; $sFilePath - Valid filepath to add to the binary bin. ; $bOverwrite - [optional] Clear the contents of the binary bin. Default is False. ; Return values .: Success - Returns data string added to the binary bin ; Failure - Returns blank string & sets @error to none-zero. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _BinaryBin_Add(ByRef $aBinaryBin, $sFilePath, $bOverwrite = False) Return __BinaryBin_AddData($aBinaryBin, $sFilePath, True, $bOverwrite, '') EndFunc ;==>_BinaryBin_Add ; #FUNCTION# ==================================================================================================================== ; Name ..........: _BinaryBin_AddFolder ; Description ...: Add a folder to a binary bin file. This is recursive i.e. it will search sub-folders too. ; Syntax ........: _BinaryBin_AddFolder(ByRef $aBinaryBin, $sFolder[, $bOverwrite = False]) ; Parameters ....: $aBinaryBin - [in/out and const] Handle created by _BinaryBin. ; $sFolder - Valid folder to add to the binary bin file. ; $bOverwrite - [optional] Clear the contents of the binary bin. Default is False. ; Return values .: Success - Array of files and folder added. ; Failure - Empty array & sets @error to none-zero. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _BinaryBin_AddFolder(ByRef $aBinaryBin, $sFolder, $bOverwrite = False) Local $aArray = 0, $aError[0], _ $iError = $BINARYBIN_ERROR_NONE If __BinaryBin_IsBinaryBin($aBinaryBin) Then $sFolder = __BinaryBin_GetDirectoryFormat($sFolder, False) If StringInStr(FileGetAttrib($sFolder), 'D', $STR_NOCASESENSEBASIC) Then Local $iPID = Run(@ComSpec & ' /C DIR /B /A-D /S', $sFolder & '\', @SW_HIDE, $STDOUT_CHILD) ; Thanks to SmOke_N. ProcessWaitClose($iPID) $aArray = StringRegExp(@ScriptFullPath & @CRLF & StdoutRead($iPID), '([^\r\n]*)(?:\R)', $STR_REGEXPARRAYGLOBALMATCH) $aArray[0] = UBound($aArray, 1) - 1 If $aArray[0] Then If $bOverwrite Then Local $sData = '' __BinaryBin_FileWrite($aBinaryBin[$BINARYBIN_HWND], $sData, True) EndIf For $i = 1 To $aArray[0] If $aArray[$i] = $aBinaryBin[$BINARYBIN_FILENAME] Then ContinueLoop EndIf __BinaryBin_AddData($aBinaryBin, $aArray[$i], True, 0, StringReplace(StringRegExpReplace($aArray[$i], '(^.*\\)(.*)', '\1'), $sFolder & '\', '')) ; Thanks to Malkey for the SRE. Next Else $aArray = $aError $iError = $BINARYBIN_ERROR_FATAL EndIf Else $aArray = $aError $iError = $BINARYBIN_ERROR_INVALIDFOLDER EndIf Else $aArray = $aError $iError = $BINARYBIN_ERROR_INVALIDBIN EndIf Return SetError($iError, 0, $aArray) EndFunc ;==>_BinaryBin_AddFolder ; #FUNCTION# ==================================================================================================================== ; Name ..........: _BinaryBin_Close ; Description ...: Close a binary bin file. ; Syntax ........: _BinaryBin_Close(Byref $aBinaryBin) ; Parameters ....: $aBinaryBin - [in/out] Handle created by _BinaryBin. ; Return values .: Success - True ; Failure - None ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _BinaryBin_Close(ByRef $aBinaryBin) Local $bReturn = False If __BinaryBin_IsBinaryBin($aBinaryBin) Then _WinAPI_CloseHandle($aBinaryBin[$BINARYBIN_HWND]) For $i = 0 To $BINARYBIN_MAX - 1 $aBinaryBin[$i] = Null Next EndIf Return $bReturn EndFunc ;==>_BinaryBin_Close ; #FUNCTION# ==================================================================================================================== ; Name ..........: _BinaryBin_Decrypt ; Description ...: Decrypt a binary bin file. ; Syntax ........: _BinaryBin_Decrypt(ByRef $aBinaryBin, $sPassword) ; Parameters ....: $aBinaryBin - [in/out and const] Handle created by _BinaryBin. ; $sPassword - Password to decrypt the binary bin file. ; Return values .: Success - True ; Failure - False ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _BinaryBin_Decrypt(ByRef $aBinaryBin, $sPassword) Local $bReturn = False If __BinaryBin_IsBinaryBin($aBinaryBin) And __BinaryBin_IsEncrypted($aBinaryBin) Then Local $bClose = _WinAPI_CloseHandle($aBinaryBin[$BINARYBIN_HWND]), _ $hFileOpen = 0, _ $sData = '' If $bClose Then $hFileOpen = FileOpen($aBinaryBin[$BINARYBIN_FILEPATH], $FO_READ) $bReturn = ($hFileOpen > -1) If $bReturn Then $sData = FileRead($hFileOpen) FileClose($hFileOpen) _Crypt_Startup() Local Const $hDeriveKey = _Crypt_DeriveKey($sPassword, $CALG_RC4) $sData = _Crypt_DecryptData($sData, $hDeriveKey, $CALG_USERKEY) $bReturn = (@error = $BINARYBIN_ERROR_NONE) _Crypt_DestroyKey($hDeriveKey) _Crypt_Shutdown() EndIf EndIf If $bReturn Then $hFileOpen = FileOpen($aBinaryBin[$BINARYBIN_FILEPATH], $FO_OVERWRITE) $bReturn = ($hFileOpen > -1) If $bReturn Then FileWrite($hFileOpen, $sData) FileClose($hFileOpen) EndIf EndIf If $bClose Then $aBinaryBin = _BinaryBin($aBinaryBin[$BINARYBIN_FILEPATH], False) EndIf EndIf Return $bReturn EndFunc ;==>_BinaryBin_Decrypt ; #FUNCTION# ==================================================================================================================== ; Name ..........: _BinaryBin_Encrypt ; Description ...: Encrypt a binary bin file. ; Syntax ........: _BinaryBin_Encrypt(ByRef $aBinaryBin, $sPassword) ; Parameters ....: $aBinaryBin - [in/out and const] Handle created by _BinaryBin. ; $sPassword - Password to encrypt the binary bin file. ; Return values .: Success - True ; Failure - False ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _BinaryBin_Encrypt(ByRef $aBinaryBin, $sPassword) Local $bReturn = False If __BinaryBin_IsBinaryBin($aBinaryBin) And Not __BinaryBin_IsEncrypted($aBinaryBin) Then Local $bClose = _WinAPI_CloseHandle($aBinaryBin[$BINARYBIN_HWND]), _ $hFileOpen = 0, _ $sData = '' If $bClose Then $hFileOpen = FileOpen($aBinaryBin[$BINARYBIN_FILEPATH], $FO_READ) $bReturn = ($hFileOpen > -1) If $bReturn Then $sData = FileRead($hFileOpen) FileClose($hFileOpen) _Crypt_Startup() Local Const $hDeriveKey = _Crypt_DeriveKey($sPassword, $CALG_RC4) $sData = _Crypt_EncryptData($sData, $hDeriveKey, $CALG_USERKEY) $bReturn = (@error = $BINARYBIN_ERROR_NONE) _Crypt_DestroyKey($hDeriveKey) _Crypt_Shutdown() EndIf EndIf If $bReturn Then $hFileOpen = FileOpen($aBinaryBin[$BINARYBIN_FILEPATH], $FO_OVERWRITE) $bReturn = ($hFileOpen > -1) If $bReturn Then FileWrite($hFileOpen, $sData) FileClose($hFileOpen) EndIf EndIf If $bClose Then $aBinaryBin = _BinaryBin($aBinaryBin[$BINARYBIN_FILEPATH], False) EndIf EndIf Return $bReturn EndFunc ;==>_BinaryBin_Encrypt ; #FUNCTION# ==================================================================================================================== ; Name ..........: _BinaryBin_Extract ; Description ...: Extract a binary bin file to a specified folder/path. ; Syntax ........: _BinaryBin_Extract(ByRef $aBinaryBin[, $sDestination = @ScriptDir[, $iIndex = -1]]) ; Parameters ....: $aBinaryBin - [in/out and const] Handle created by _BinaryBin. ; $sDestination - [optional] Destination filepath to extract the files to. Default is @ScriptDir. ; $iIndex - [optional] Index number of the file to extract. Default is -1 all contents. ; Return values .: Success - True ; Failure - False ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _BinaryBin_Extract(ByRef $aBinaryBin, $sDestination = @ScriptDir, $iIndex = -1) Local $bReturn = False If __BinaryBin_IsBinaryBin($aBinaryBin) Then If $iIndex = Default Then $iIndex = -1 EndIf Local $aArray = __BinaryBin_Process($aBinaryBin[$BINARYBIN_HWND]) Local $iCount = $iIndex $sDestination = __BinaryBin_GetDirectoryFormat($sDestination, True) If $iIndex <= 0 Or $iIndex > $aArray[0][0] Then $iCount = 1 $iIndex = $aArray[0][0] EndIf Local $hFileOpen = 0 $bReturn = $aArray[0][0] > 0 If $bReturn Then For $i = $iCount To $iIndex DirCreate($sDestination & '\' & $aArray[$i][2]) $hFileOpen = FileOpen($sDestination & '\' & $aArray[$i][2] & $aArray[$i][1], BitOR($FO_APPEND, $FO_BINARY)) If $hFileOpen = -1 Then ContinueLoop EndIf FileWrite($hFileOpen, Binary($aArray[$i][0])) FileClose($hFileOpen) Next EndIf EndIf Return $bReturn EndFunc ;==>_BinaryBin_Extract ; #FUNCTION# ==================================================================================================================== ; Name ..........: _BinaryBin_GetFileCount ; Description ...: Retrieve the file count in a binary bin file. ; Syntax ........: _BinaryBin_GetFileCount(ByRef $aBinaryBin) ; Parameters ....: $aBinaryBin - [in/out and const] Handle created by _BinaryBin. ; Return values .: Success - File count. ; Failure - 0 sets @error to non-zero. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _BinaryBin_GetFileCount(ByRef $aBinaryBin) Local $iError = $BINARYBIN_ERROR_NONE, $iReturn = 0 If __BinaryBin_IsBinaryBin($aBinaryBin) Then Local Const $sData = __BinaryBin_FileRead($aBinaryBin[$BINARYBIN_HWND]) Local Const $aSRE = StringRegExp($sData, '<filename>([^<]*)</filename>', $STR_REGEXPARRAYGLOBALMATCH) If @error Then $iError = $BINARYBIN_ERROR_INVALIDFILENAME Else $iReturn = UBound($aSRE) EndIf Else $iError = $BINARYBIN_ERROR_INVALIDBIN EndIf Return SetError($iError, 0, $iReturn) EndFunc ;==>_BinaryBin_GetFileCount ; #FUNCTION# ==================================================================================================================== ; Name ..........: _BinaryBin_GetFolders ; Description ...: Retrieve the list of files in a binary bin file. ; Syntax ........: _BinaryBin_GetFolders(ByRef $aBinaryBin[, $sDestination = @ScriptDir]) ; Parameters ....: $aBinaryBin - [in/out and const] Handle created by _BinaryBin. ; Return values .: Success - An array containing a list of files. ; Failure - Empty array & sets @error to non-zero. ; Author ........: guinness ; Remarks........: The array returned is one-dimensional and is made up as follows: ; $aArray[0] = Number of files ; $aArray[1] = 1st file ; $aArray[2] = 2nd file ; $aArray[3] = 3rd File ; $aArray[n] = nth file ; Example .......: Yes ; =============================================================================================================================== Func _BinaryBin_GetFiles(ByRef $aBinaryBin) Local $aError[0], $aReturn = 0, _ $iError = $BINARYBIN_ERROR_NONE If __BinaryBin_IsBinaryBin($aBinaryBin) Then Local $sData = __BinaryBin_FileRead($aBinaryBin[$BINARYBIN_HWND]) $aReturn = StringRegExp('<filename>GetBinFilesCount</filename>' & @CRLF & $sData, '<filename>([^<]*)</filename>', $STR_REGEXPARRAYGLOBALMATCH) If @error Then $aReturn = $aError $iError = $BINARYBIN_ERROR_INVALIDFILENAME Else $aReturn[0] = UBound($aReturn, 1) - 1 EndIf Else $aReturn = $aError $iError = $BINARYBIN_ERROR_INVALIDBIN EndIf Return SetError($iError, 0, $aReturn) EndFunc ;==>_BinaryBin_GetFiles ; #FUNCTION# ==================================================================================================================== ; Name ..........: _BinaryBin_GetFolders ; Description ...: Retrieve the list of folders in a binary bin file. ; Syntax ........: _BinaryBin_GetFolders(ByRef $aBinaryBin[, $sDestination = @ScriptDir]) ; Parameters ....: $aBinaryBin - [in/out and const] Handle created by _BinaryBin. ; $sDestination - [optional] Destination filepath to extract the folders to. Default is @ScriptDir. ; Return values .: Success - An array containing a list of folders. ; Failure - Empty array & sets @error to non-zero. ; Author ........: guinness ; Remarks........: The array returned is one-dimensional and is made up as follows: ; $aArray[0] = Number of folders ; $aArray[1] = 1st folder ; $aArray[2] = 2nd folder ; $aArray[3] = 3rd folder ; $aArray[n] = nth folder ; Example .......: Yes ; =============================================================================================================================== Func _BinaryBin_GetFolders(ByRef $aBinaryBin, $sDestination = @ScriptDir) Local $aError[0], $aReturn = 0, _ $iError = $BINARYBIN_ERROR_NONE If __BinaryBin_IsBinaryBin($aBinaryBin) Then If $sDestination = Default Then $sDestination = @ScriptDir EndIf Local $sData = __BinaryBin_FileRead($aBinaryBin[$BINARYBIN_HWND]) $sDestination = __BinaryBin_GetDirectoryFormat($sDestination, False) $aReturn = StringRegExp('<folder>GetBinFoldersCount</folder>' & @CRLF & $sData, '<folder>([^<]*)</folder>', $STR_REGEXPARRAYGLOBALMATCH) If @error Then $aReturn = $aError $iError = $BINARYBIN_ERROR_INVALIDFOLDER Else $aReturn[0] = UBound($aReturn, 1) - 1 Local Const $sSOH = Chr(01) Local $sReturn = '' For $i = 1 To $aReturn[0] If Not StringInStr($sSOH & $sReturn, $sSOH & $sDestination & '\' & $aReturn[$i] & $sSOH, $STR_NOCASESENSEBASIC) Then $sReturn &= $sDestination & '\' & $aReturn[$i] & $sSOH EndIf Next $aReturn = StringSplit(StringTrimRight($sReturn, StringLen($sSOH)), $sSOH) If @error Then $aReturn = $aError $iError = $BINARYBIN_ERROR_INVALIDFOLDER EndIf EndIf Else $aReturn = $aError $iError = $BINARYBIN_ERROR_INVALIDBIN EndIf Return SetError($iError, 0, $aReturn) EndFunc ;==>_BinaryBin_GetFolders ; #FUNCTION# ==================================================================================================================== ; Name ..........: _BinaryBin_GetSize ; Description ...: Retrieve the filesize of a BinaryBin file. ; Syntax ........: _BinaryBin_GetSize(ByRef $aBinaryBin[, $bFormatted = False]) ; Parameters ....: $aBinaryBin - [in/out and const] Handle created by _BinaryBin. ; $bFormatted - [optional] Return as a user friendly output e.g. 1000 bytes >> 1 KB. Default is False. ; Return values .: Success - Filesize ; Failure - 0 ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _BinaryBin_GetSize(ByRef $aBinaryBin, $bFormatted = False) Local $iSize = 0 If __BinaryBin_IsBinaryBin($aBinaryBin) Then $iSize = _WinAPI_GetFileSizeEx($aBinaryBin[$BINARYBIN_HWND]) EndIf Return ($bFormatted ? __BinaryBin_ByteSuffix($iSize, 2) : $iSize) EndFunc ;==>_BinaryBin_GetSize ; #FUNCTION# ==================================================================================================================== ; Name ..........: _BinaryBin_GetFileName ; Description ...: Rerieve the filename of a handle returned by _BinaryBin. ; Syntax ........: _BinaryBin_GetFileName(ByRef $aBinaryBin) ; Parameters ....: $aBinaryBin - [in/out and const] Handle created by _BinaryBin. ; Return values .: Success - Filename ; Failure - Null ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _BinaryBin_GetFileName(ByRef $aBinaryBin) Return __BinaryBin_IsBinaryBin($aBinaryBin) ? $aBinaryBin[$BINARYBIN_FILENAME] : Null EndFunc ;==>_BinaryBin_GetFileName ; #FUNCTION# ==================================================================================================================== ; Name ..........: _BinaryBin_GetFilePath ; Description ...: Rerieve the filepath of a handle returned by _BinaryBin. ; Syntax ........: _BinaryBin_GetFilePath(ByRef $aBinaryBin) ; Parameters ....: $aBinaryBin - [in/out and const] Handle created by _BinaryBin. ; Return values .: Success - Filepath ; Failure - Null ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _BinaryBin_GetFilePath(ByRef $aBinaryBin) Return __BinaryBin_IsBinaryBin($aBinaryBin) ? $aBinaryBin[$BINARYBIN_FILEPATH] : Null EndFunc ;==>_BinaryBin_GetFilePath ; #FUNCTION# ==================================================================================================================== ; Name ..........: _BinaryBin_IsEncrypted ; Description ...: Check if a binary bin file is encrypted. ; Syntax ........: _BinaryBin_IsEncrypted(ByRef $aBinaryBin) ; Parameters ....: $aBinaryBin - [in/out and const] Handle created by _BinaryBin. ; Return values .: Success - True ; Failure - False ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _BinaryBin_IsEncrypted(ByRef $aBinaryBin) Return __BinaryBin_IsBinaryBin($aBinaryBin) ? __BinaryBin_IsEncrypted($aBinaryBin) : Null EndFunc ;==>_BinaryBin_IsEncrypted ; #INTERNAL_USE_ONLY#============================================================================================================ Func __BinaryBin_AddData(ByRef $aBinaryBin, $sFilePath, $bWrite, $bOverwrite, $sFolder) Local $sData = '' If __BinaryBin_IsBinaryBin($aBinaryBin) Then Local $hFileOpen = FileOpen($sFilePath, $FO_BINARY) If $hFileOpen = -1 Then Return SetError($BINARYBIN_ERROR_FATAL, 0, $sData) EndIf $sData = '<data>' & Binary(FileRead($hFileOpen)) & '</data>' & _ '<filename>' & __BinaryBin_GetFileName($sFilePath) & '</filename>' & _ '<folder>' & $sFolder & '</folder>' & @CRLF FileClose($hFileOpen) If $bWrite Then __BinaryBin_FileWrite($aBinaryBin[$BINARYBIN_HWND], $sData, $bOverwrite) If @error Then $sData = '' Return SetError($BINARYBIN_ERROR_FATAL, 0, $sData) EndIf EndIf EndIf Return $sData EndFunc ;==>__BinaryBin_AddData Func __BinaryBin_ByteSuffix($iBytes, $iRound) Local $aArray = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], _ $iIndex = 0 While $iBytes > 1023 $iIndex += 1 $iBytes /= 1024 WEnd Return Round($iBytes, $iRound) & ' ' & $aArray[$iIndex] EndFunc ;==>__BinaryBin_ByteSuffix Func __BinaryBin_FileRead($hFilePath) Local $iFileSize = (_WinAPI_GetFileSizeEx($hFilePath) + 1), _ $sText = '' Local $tBuffer = DllStructCreate('byte array[' & $iFileSize & ']') _WinAPI_SetFilePointer($hFilePath, 0) _WinAPI_ReadFile($hFilePath, DllStructGetPtr($tBuffer), $iFileSize, $sText) Return SetError(@error, 0, BinaryToString(DllStructGetData($tBuffer, 'array'))) EndFunc ;==>__BinaryBin_FileRead Func __BinaryBin_FileWrite($hFilePath, ByRef $sText, $bOverwrite) If $bOverwrite Then _WinAPI_SetFilePointer($hFilePath, $FILE_BEGIN) _WinAPI_SetEndOfFile($hFilePath) EndIf Local $iFileSize = _WinAPI_GetFileSizeEx($hFilePath), $iLength = StringLen($sText), $iWritten = 0 Local $tBuffer = DllStructCreate('byte array[' & $iLength & ']') DllStructSetData($tBuffer, 'array', $sText) _WinAPI_SetFilePointer($hFilePath, $iFileSize) _WinAPI_WriteFile($hFilePath, DllStructGetPtr($tBuffer), $iLength, $iWritten) Return SetError(@error, @extended, $iWritten) EndFunc ;==>__BinaryBin_FileWrite Func __BinaryBin_GetDirectoryFormat($sFolder, $bCreate) $sFolder = StringRegExpReplace($sFolder, '[\\/]+$', '') ; Strip the last backslash. If $bCreate And Not FileExists($sFolder) Then DirCreate($sFolder) EndIf Return $sFolder EndFunc ;==>__BinaryBin_GetDirectoryFormat Func __BinaryBin_GetFileName($sFilePath) Return StringRegExpReplace($sFilePath, '^.+[\\/]', '') ; Thanks to Malkey. EndFunc ;==>__BinaryBin_GetFileName Func __BinaryBin_IsBinaryBin(ByRef $aBinaryBin) Return UBound($aBinaryBin) = $BINARYBIN_MAX And $aBinaryBin[$BINARYBIN_ID] = $BINARYBIN_GUID EndFunc ;==>__BinaryBin_IsBinaryBin Func __BinaryBin_IsEncrypted(ByRef $aBinaryBin) Return Not StringInStr(__BinaryBin_FileRead($aBinaryBin[$BINARYBIN_HWND]), 'data') EndFunc ;==>__BinaryBin_IsEncrypted Func __BinaryBin_Process($hFilePath) Local Const $iColumns = 3 Local $sData = __BinaryBin_FileRead($hFilePath) Local $aArray = StringRegExp($sData, '<data>(0x[[:xdigit:]]+)</data><filename>([^<]*)</filename><folder>([^<]*)</folder>', $STR_REGEXPARRAYGLOBALMATCH) If @error Then Local $aError[1][$iColumns] = [[0, $iColumns]] Return SetError($BINARYBIN_ERROR_INVALIDBIN, 0, $aError) EndIf Local $iColumn = 0, $iIndex = 0, $iUbound = UBound($aArray, 1) Local $aReturn[($iUbound / $iColumns) + 1][$iColumns] = [[0, $iColumns]] For $i = 0 To $iUbound - 1 Step $iColumns $iColumn = 0 $iIndex += $iColumns $aReturn[0][0] += 1 For $j = $i To $iIndex - 1 $aReturn[$aReturn[0][0]][$iColumn] = $aArray[$j] $iColumn += 1 Next Next Return $aReturn EndFunc ;==>__BinaryBin_ProcessExample 1:expandcollapse popup#include '_BinaryBin.au3' Example() Func Example() ; Open the BinaryBin.bin file and erase previous contents. Local $hBinFile = _BinaryBin(@ScriptDir & '\BinaryBin.bin', True) Local $sFolder = FileSelectFolder('_BinaryBin Folder to add to the BinaryBin.bin file.', '') If @error Then Return False ; Return if no folder was selected. ; Add a Folder to the BinaryBin.bin file. _BinaryBin_AddFolder($hBinFile, $sFolder, False) ; Check the files added to the BinaryBin.bin file and display in _ArrayDisplay(). Local $aArray = _BinaryBin_GetFiles($hBinFile) _ArrayDisplay($aArray, '_BinaryBin File Names') ; Check the folders added to the BinaryBin.bin file and display in _ArrayDisplay(). $aArray = _BinaryBin_GetFolders($hBinFile, @ScriptDir & '\Export') _ArrayDisplay($aArray, '_BinaryBin Folders') ; Retrieve the number of files before encrypting. Local $iFileCount = _BinaryBin_GetFileCount($hBinFile) ; Encrypt the BinaryBin.bin file with the password - Password. _BinaryBin_Encrypt($hBinFile, 'Password') Local $sData = '_BinaryBin FileSize: ' & _BinaryBin_GetSize($hBinFile, 1) & @CRLF ; Display additional details about the BinaryBin.bin file. $sData &= '_BinaryBin File Count: ' & $iFileCount & @CRLF $sData &= '_BinaryBin is Encrypted: ' & _BinaryBin_IsEncrypted($hBinFile) & @CRLF $sData &= '_BinaryBin FilePath: ' & _BinaryBin_GetFilePath($hBinFile) & @CRLF MsgBox($MB_SYSTEMMODAL, '_BinaryBin Data', $sData) ; Decrypt the BinaryBin.bin file with the password - Password. _BinaryBin_Decrypt($hBinFile, 'Password') ; Close the BinaryBin.bin handle. _BinaryBin_Close($hBinFile) EndFunc ;==>ExampleExample 2:#include '_BinaryBin.au3' Example() Func Example() ; Open the BinaryBin.bin file and don't erase previous contents. Local $hBinFile = _BinaryBin(@ScriptDir & '\BinaryBin.bin', False) ; Decrypt the BinaryBin.bin file with the password - Password. _BinaryBin_Decrypt($hBinFile, 'Password') MsgBox($MB_SYSTEMMODAL, '_BinaryBin Extraction', 'Extracting the BinaryBin.bin to ' & @ScriptDir & '\Export results in the return value of: ' & @CRLF & _ 'Return: ' & _BinaryBin_Extract($hBinFile, @ScriptDir & '\Export')) ; Close the BinaryBin.bin handle. _BinaryBin_Close($hBinFile) EndFunc ;==>ExampleAll of the above has been included in a ZIP file. BinaryBin.zipPrevious download 330+Warning: This is ideal for moderately small files, anything in the excess of 100 MB's is probably best to look elsewhere e.g. 7-Zip Edited October 6, 2014 by guinness Alenis and JScript 2 UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
BrewManNH Posted May 16, 2011 Share Posted May 16, 2011 You might find that using the _RecFileListToArray without the sorting will be much faster, unless you need to have the file array sorted on the return. From what I see as to how you're using the array, it doesn't look like it needs to be sorted when you're adding files/folders. Also, you can probably get away with using just the _BinaryBin_AddFolderEx() function because you can set the _RFLTA function to not recurse the folder if you wanted. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
guinness Posted May 16, 2011 Author Share Posted May 16, 2011 (edited) You might find that using the _RecFileListToArray without the sorting will be much faster, unless you need to have the file array sorted on the return.It has to be sorted because of the subfolders. Otherwise it would be a lot slower. (Unless I'm wrong?!)From what I see as to how you're using the array, it doesn't look like it needs to be sorted when you're adding files/folders. Also, you can probably get away with using just the _BinaryBin_AddFolderEx() function because you can set the _RFLTA function to not recurse the folder if you wanted.True! I suppose because I created the _FileListToArray() Function first I didn't think to add into _RecFileListToArray() and then remove And I was expecting users to say can we have a version with only _FileListToArray()!!Cheers for the tips BrewManNH! (Is this payback?!) Edited May 16, 2011 by guinness UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
BrewManNH Posted May 16, 2011 Share Posted May 16, 2011 It only really matters if you're going through a lot of files whether sorting affects the time or not. I know that when I used it with the folder that holds all my music files (over 6000 files/folders) when I used the sort parameter it took 23+ seconds compared to about .6 seconds without. I suppose you can always test it to see if it makes a difference in speed sorting/not sorting in regards to the overall time required. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
guinness Posted May 16, 2011 Author Share Posted May 16, 2011 I remember now why I need to sort the Array! Because I start from the top of the Array and if not a folder assume this as the Parent Folder, if SubFolder found then assume this is the SubFolder of the next files in the list until another SubFolder is found and continue. Without sorting this makes things messy. UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
BrewManNH Posted May 16, 2011 Share Posted May 16, 2011 Understandable why you sort now. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
guinness Posted May 16, 2011 Author Share Posted May 16, 2011 Thanks for taking the time to Help! I'm sure I will add extra features in the coming weeks. UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
guinness Posted November 19, 2011 Author Share Posted November 19, 2011 (edited) The UDF has just been updated with improved syntax and an increase in speed. I removed _BinaryBin_AddFolderEx() and improved _BinaryBin_AddFolder() tenfold. Any suggestions then please post below. Edited November 19, 2011 by guinness UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
mesale0077 Posted October 14, 2012 Share Posted October 14, 2012 (edited) hi Example_1 (Creation).au3 working but Example_3 (Compression).au3 error line $bData = Binary(__BinaryBin_FileWrite($sFilePath, 16)) error and Example_2 (Extraction).au3 dont work all file total size < 2.5mb why ? thank you now Edited October 14, 2012 by mesale0077 Link to comment Share on other sites More sharing options...
guinness Posted October 14, 2012 Author Share Posted October 14, 2012 I will have a look and re-tweak this UDF. I have a couple of ideas on how to improve it. Thanks for reporting. UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
guinness Posted October 15, 2012 Author Share Posted October 15, 2012 I completely re-coded this UDF from scratch as I wanted to remove the unnecessary Global variable, so this is one major script breaking change as now you have to pass a variable returned by _BinaryBin_Open to all relevant functions. I also improved the speed of the UDF and fixed an issue with compressing a binary bin file. As I said this is a brand new UDF so please look at the documentation as well as the examples provided. Thanks. UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
guinness Posted October 16, 2012 Author Share Posted October 16, 2012 Another massive change to the UDF. I have taken the idea from my (lock a file,) so now the binary bin file is locked to the current process, plus the opening and closing of the binary bin file is minimised due to it being opened with _BinaryBin_Open and closed with _BinaryBin_Close. I did this because with the native FileOpen results may vary with having a file in both read and write access. Please see the original post for more details. UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
guinness Posted October 19, 2012 Author Share Posted October 19, 2012 Added the function _BinaryBin_GetFileFromHandle to the UDF. See original post for more details. UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
JScript Posted October 19, 2012 Share Posted October 19, 2012 Wow! You have so many UDFs that I had not seen this... Excellent idea, I will test and feedback, thanks for sharing JS http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
guinness Posted June 5, 2013 Author Share Posted June 5, 2013 Updated the UDF with optimising the return types and using Ascend4nt's post on >short-circuit evaluation to improve the If...EndIf statements. I also (you guessed it) removed the 'magic numbers' and opting for using the equivalent constant variables. UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
guinness Posted May 24, 2014 Author Share Posted May 24, 2014 If you have been using this UDF then you should know it's changed from the original quite a bit, with an entire re-write that is inline with how I now code in AutoIt. If you have any questions then please let me know. Thanks. UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
MagicSpark Posted July 22, 2014 Share Posted July 22, 2014 Hello guinness, I want to let you know that there are errors if you run the posted example for Creation. I think after you updated the UDF, you forgot to update the examples? Thanks. Link to comment Share on other sites More sharing options...
guinness Posted July 23, 2014 Author Share Posted July 23, 2014 Sorry about that. I have updated the example and did a bit of maintenance work in the process. Note: The error was due to removing "bin" from the functions as I found it unnessary.  Changed: _BinaryBin_Open() to _BinaryBin(). This matches the same style I have adopted in most of my UDFs. Fixed: Variable renaming from $f to $b for the boolean datatype. Fixed: _BinaryBin_GetSize(), which returns a formatted string even if the variable passed isn't a binary bin object. Fixed: Magic number usage for StringRegExp(). Fixed: Error reporting in functions that use an enuneration. Fixed: The examples. (Thanks MagicSpark) Removed: Unused includes.  UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
vincend Posted September 23, 2014 Share Posted September 23, 2014 hi, I'm sorry but the script does not work (for me) arrays are empty for folders like files ( __BinaryBin_FileWrite() return 0) I thought to create a script with $cmdline... thank to solve the problem (if the problem is not me) Link to comment Share on other sites More sharing options...
guinness Posted September 24, 2014 Author Share Posted September 24, 2014 That function is internal and should be used by the end user. Did you try the example? UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 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