Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/19/2012 in all areas

  1. JLogan3o13

    Windows Firewall UDF

    I dug this UDF out in response to a request in the General Help forum. There is still some tidying to do, but I thought I would post here for anyone that would benefit. All functions have been tested on both XP and Windows 7. Updated January 22, 2014: Tested on XP, WIN7 and WIN8.1, x86 and x64 Current version includes: Enable or Disable the Windows Firewall Add or Remove Authorized Applications to the Exclusions list Add or Delete Ports from the Exclusions list. Enable or Disable the use of Exceptions Enable or Disable Notifications of blocked applications Enable or Disable Existing Ports List all Applications in the Exclusions List List all Ports in the Exclusions List List Properties of the current Firewall Configuration Restore the Windows Firewall to its default configuration Windows Firewall.au3
    1 point
  2. Hello, I needed to read and write dBase files. so I searched the internet and found the shapelib library (http://shapelib.maptools.org/). I compiled the DBF part of it to make a small DLL and build some wrapper functions around it. Function description is here: http://shapelib.maptools.org/dbf_api.html. I know this can be done with COM, but I hope DLL version is faster than it and faster than SQLite. But I haven't done testing yet. Maybe someone needs this UDF. Download: http://autoit.de/index.php/Attachment/16455-DBF-rar/ BR funkey Edit: Added examples
    1 point
  3. This UDF has been rewritten - the new version can be found here. ---------------------------------------------------------------------------------------------- [New version] - 28 Aug 16 Added: The UDF is now RTL sensitive. Thanks to shai for the request. New UDF and examples below. Details of previous versions: The GUIExtender UDF allows you to have multiple sections within your GUIs which can be either static or extendable. The extendable sections can be extended and retracted either by UDF created buttons or programmatically by other controls or HotKeys. The controls on the sections are fully functional and there is no overlap problem when retracted (see the details section if you want to know how). The UDF can be used in both MessageLoop and OnEvent modes and with both native and UDF created controls, as well as embedded objects and child GUIs. Details of how the UDF works for those who are interested: The UDF and plenty of commented examples are in the attached zip: As always, happy to receive brickbats or bouquets. M23
    1 point
  4. 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: #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_Process Example 1: #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 ;==>Example Example 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 ;==>Example All 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
    1 point
  5. HotKeySet("{Esc}","esc") Global $board[8][8] For $x=1 To 7 Step +1 for $y=1 To 6 Step + 1 $board[$x][$y]=0 Next Next Global $turn = 1 Global $a1 = 250 Global $a2 = 250 Global $a3 = 250 Global $a4 = 250 Global $a5 = 250 Global $a6 = 250 Global $a7 = 250 Global $play = 1 Global $color = 0xff0000 Func esc() Exit EndFunc #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Four Stars", 350, 350, -1,-1) $b1 = GUICtrlCreateButton("1",0,300,50,50) $b2 = GUICtrlCreateButton("2",50,300,50,50) $b3 = GUICtrlCreateButton("3",100,300,50,50) $b4 = GUICtrlCreateButton("4",150,300,50,50) $b5 = GUICtrlCreateButton("5",200,300,50,50) $b6 = GUICtrlCreateButton("6",250,300,50,50) $b7 = GUICtrlCreateButton("7",300,300,50,50) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 if mod($turn,2) = 0 Then $play = 2 $color=0x0000ff Else $play = 1 $color=0xff0000 EndIf if $a1 < 0 Then GUICtrlSetState($b1,$GUI_HIDE) EndIf if $a2 < 0 Then GUICtrlSetState($b2,$GUI_HIDE) EndIf if $a3 < 0 Then GUICtrlSetState($b3,$GUI_HIDE) EndIf if $a4 < 0 Then GUICtrlSetState($b4,$GUI_HIDE) EndIf if $a5 < 0 Then GUICtrlSetState($b5,$GUI_HIDE) EndIf if $a6 < 0 Then GUICtrlSetState($b6,$GUI_HIDE) EndIf if $a7 < 0 Then GUICtrlSetState($b7,$GUI_HIDE) EndIf $m = GUIGetMsg() Switch $m Case $GUI_EVENT_CLOSE Exit Case $b1 GUICtrlCreateButton($play,0,$a1,50,50) GUICtrlSetBkColor(-1,$color) $turn = $turn + 1 $yi= $a1/50+1 $board[1][$yi]=$play $a1 = $a1 - 50 check() Case $b2 GUICtrlCreateButton($play,50,$a2,50,50) GUICtrlSetBkColor(-1,$color) $turn = $turn + 1 $yi= $a2/50+1 $board[2][$yi]=$play $a2 = $a2 - 50 check() Case $b3 GUICtrlCreateButton($play,100,$a3,50,50) GUICtrlSetBkColor(-1,$color) $turn = $turn + 1 $yi= $a3/50+1 $board[3][$yi]=$play $a3 = $a3 - 50 check() Case $b4 GUICtrlCreateButton($play,150,$a4,50,50) GUICtrlSetBkColor(-1,$color) $turn = $turn + 1 $yi= $a4/50+1 $board[4][$yi]=$play $a4 = $a4 - 50 check() Case $b5 GUICtrlCreateButton($play,200,$a5,50,50) GUICtrlSetBkColor(-1,$color) $turn = $turn + 1 $yi= $a5/50+1 $board[5][$yi]=$play $a5 = $a5 - 50 check() Case $b6 GUICtrlCreateButton($play,250,$a6,50,50) GUICtrlSetBkColor(-1,$color) $turn = $turn + 1 $yi= $a6/50+1 $board[6][$yi]=$play $a6 = $a6 - 50 check() Case $b7 GUICtrlCreateButton($play,300,$a7,50,50) GUICtrlSetBkColor(-1,$color) $turn = $turn + 1 $yi= $a7/50+1 $board[7][$yi]=$play $a7 = $a7 - 50 check() EndSwitch WEnd Func check() For $t=1 to 2 Step +1 For $x=1 to 4 step +1 For $y = 6 to 4 step -1 if $board[$x][$y]=$t And $board[$x+1][$y-1]=$t And $board[$x+2][$y-2]=$t And $board[$x+3][$y-3]=$t Then MsgBox(0,"The winner is","Player" & $t) Exit EndIf Next Next For $x=1 To 4 Step +1 for $y=1 To 6 Step + 1 if $board[$x][$y]=$t And $board[$x][$y+1]=$t And $board[$x][$y+2]=$t And $board[$x][$y+3]=$t Then MsgBox(0,"The winner is","Player" & $t) Exit EndIf if $board[$x][$y]=$t And $board[$x+1][$y]=$t And $board[$x+2][$y]=$t And $board[$x+3][$y]=$t Then MsgBox(0,"The winner is","Player" & $t) Exit EndIf if $board[$x][$y]=$t And $board[$x+1][$y+1]=$t And $board[$x+2][$y+2]=$t And $board[$x+3][$y+3]=$t Then MsgBox(0,"The winner is","Player" & $t) Exit EndIf Next Next Next EndFunc
    1 point
  6. @MrCreatoR The includes are not supposed to have errors. I suggest to add separate line number for includes. Getting the full script line number is not efficient, you need to obfsucate it to get the right line number. Br, FireFox.
    1 point
  7. hehe. Nice, I just won myself too.
    1 point
  8. Melba23

    help with aligning GUI

    sbrady, Please stop reporting threads where people tell you to read the Help file. You are not being bullied - as I mentioned to you in another thread, given the self-evident lack of effort on your part so far, I am quite frankly amazed that people are still trying to help you. Especially when you appear to ignore much of the advice given to you - did you even read my post above? Of the questions you have asked so far in this thread, the majority could have been avoided by you reading the Help file for each of the functions used in your script. For example, the size of the GUI. And as for having 2 input controls - with 2 GUICtrlCreateInput lines surely that is self-evident. So, please start acting like the intelligent person I am sure you are and start applying some of that intelligence to understanding the code you are using. M23
    1 point
  9. 5* for me. More one improvement, if the exception is so big, there is no scroll bar!
    1 point
  10. water

    False VS 0

    I use the @error approach all the time. It's easy and reliable. You call a function. You check @error so you can see if the function returned valid data. If the data is valid, go on and process it, else send an error message to the user. BTW: Do you juggle?
    1 point
  11. I'm glad you like it. Another example: #include <Array.au3> #include <Date.au3> #include "DBF.au3" Global $hDBF = _DBF_Create("Test.dbf") If $hDBF = 0 Then ConsoleWrite("Error creating dbf file ..." & @CRLF) Exit EndIf _DBF_AddField($hDBF, "ID", $DBF_FTInteger, 10, 0) _DBF_AddField($hDBF, "Time", $DBF_FTString, 24, 0) _DBF_AddField($hDBF, "Value1", $DBF_FTDouble, 10, 3) _DBF_AddField($hDBF, "Value2", $DBF_FTDouble, 10, 3) _DBF_AddField($hDBF, "Value3", $DBF_FTDouble, 10, 3) _DBF_AddField($hDBF, "Value4", $DBF_FTDouble, 10, 3) For $i = 1 To 100 _WriteValues($hDBF) Next Global $aDBF = _DBF_DBFToArray($hDBF) _DBF_Close($hDBF) _ArrayDisplay($aDBF) Func _WriteValues($hDBF) $iRecords = _DBF_GetRecordCount($hDBF) _DBF_WriteIntegerAttribute($hDBF, $iRecords, 0, $iRecords + 1) _DBF_WriteStringAttribute($hDBF, $iRecords, 1, _Now() & "." & @MSEC) _DBF_WriteDoubleAttribute($hDBF, $iRecords, 2, Random(1, 100)) _DBF_WriteDoubleAttribute($hDBF, $iRecords, 3, Random(1, 100)) _DBF_WriteDoubleAttribute($hDBF, $iRecords, 4, Random(1, 100)) _DBF_WriteDoubleAttribute($hDBF, $iRecords, 5, Random(1, 100)) EndFunc
    1 point
  12. Hello everyone. 3 days back, I came across "El Torito" Bootable CD-ROM Format Specification. I was able to write this simple script to extract Boot-Image from a CD/DVD/ISO file. Here is it: #include <WinAPI.au3> Global $nBytes ConsoleWrite("Boot-Image X-tract (by MKISH)" & @crlf & @crlf & "USAGE: bootext.exe <PATH> <IMGNAME>") If $CmdLine[0] = 0 then Exit If NOT FileExists($CmdLine[1]) then Exit $PATH = $CmdLine[1] $RESULT = $CmdLine[2] $hFile = _WinAPI_CreateFile("." & $PATH, 2,2) $xBuffer = DllStructCreate("byte["& 4 & "]") _WinAPI_SetFilePointer($hFile, 0x11*0x800 + 0x47) _WinAPI_ReadFile($hFile, DllStructGetPtr($xBuffer), 4, $nBytes) $sText1 = DllStructGetData($xBuffer, 1) $dBuffer = DllStructCreate("byte["& 4 & "]") _WinAPI_SetFilePointer($hFile, 0x800 * Int($sText1) + 0x20 + 0x8) _WinAPI_ReadFile($hFile, DllStructGetPtr($dBuffer), 4, $nBytes) $sText2 = DllStructGetData($dBuffer, 1) $fBuffer = DllStructCreate("byte["& 1 & "]") _WinAPI_SetFilePointer($hFile, 0x800 * Int($sText1) + 0x20 + 1) _WinAPI_ReadFile($hFile, DllStructGetPtr($fBuffer), 1, $nBytes) $sTextd = DllStructGetData($fBuffer, 1) $pBuffer = DllStructCreate("byte["& 2 & "]") _WinAPI_SetFilePointer($hFile, 0x800 * Int($sText1) + 0x20 + 0x6) _WinAPI_ReadFile($hFile, DllStructGetPtr($pBuffer), 2, $nBytes) $sText3 = SecCount() $zBuffer = DllStructCreate("byte[" & $sText3 * 0x200 & "]") _WinAPI_SetFilePointer($hFile, 0x800 * Int($sText2)) _WinAPI_ReadFile($hFile, DllStructGetPtr($zBuffer), $sText3 * 0x200, $nBytes) $sText4 = DllStructGetData($zBuffer, 1) FileWrite("" & $RESULT, $sText4) _WinAPI_CloseHandle($hFile) Func SecCount() $fBuffer = DllStructCreate("byte["& 1 & "]") _WinAPI_SetFilePointer($hFile, 0x800 * Int($sText1) + 0x20 + 1) _WinAPI_ReadFile($hFile, DllStructGetPtr($fBuffer), 1, $nBytes) Switch DllStructGetData($fBuffer, 1) Case 0x00 Return Int(DllStructGetData($pBuffer, 1)) Case 0x01 Return Int(0x50 * 0x02 * 0x0F) Case 0x02 Return Int(0x50 * 0x02 * 0x12) Case 0x03 Return Int(0x50 * 0x02 * 0x24) EndSwitch EndFunc Just compile this as CUI App. Hope it is of use to somebody. Useful suggestions are welcome. EDIT: The link is working now. A bugfix
    1 point
  13. 1 point
  14. Sam83

    Window Info Control Style

    Hi, I encountered the same problem (I couldn't get the correct value with the above function) and found a solution so I post it here in case it can help anyone. I wrote this little function (quick & dirty) that uses the GetWindowInfo function of user32.dll (MSDN GetWindowInfo). It can be improved by adding error control, but it shows you how to get the info you want. You must use the handle to your control as parameter (e.g. with ControlGetHandle). It returns the style value as it can be seen in Au3info, but you can change it to get the ExStyle or anything else returned by GetWindowInfo. $hnd = ControlGetHandle('MyWindow', '', 'MyButton') GetButtonStyle($hnd) Func GetButtonStyle($handle) Local $PWINDOWINFO = "DWORD cbSize;" & _ "LONG left1;" & _ "LONG top1;" & _ "LONG right1;" & _ "LONG bottom1;" & _ "LONG left2;" & _ "LONG top2;" & _ "LONG right2;" & _ "LONG bottom2;" & _ "DWORD dwStyle;" & _ "DWORD dwExStyle;" & _ "DWORD dwWindowStatus;" & _ "UINT cxWindowBorders;" & _ "UINT cyWindowBorders;" & _ "UINT atomWindowType;" & _ "WORD wCreatorVersion;" Local $Struct = DllStructCreate($PWINDOWINFO) DllCall("user32.dll", "int", "GetWindowInfo", "hwnd", $hnd, "ptr", DllStructGetPtr($Struct)) Return Hex(DllStructGetData($Struct, "dwStyle")) EndFunc
    1 point
  15. woleium

    regwrite dword problem

    d'oh CODE RegWrite ( "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" ,"StartMenuFavorites", "DWORD", "00000000" )
    1 point
×
×
  • Create New...