Leaderboard
Popular Content
Showing content with the highest reputation on 11/26/2013 in all areas
-
_AutoItErrorTrap.au3 (UDF) - Error detection in AutoIt scripts!
GoogleDude reacted to JScript for a topic
Function Reference _AutoItErrorTrap.au3 UDF to intercept the error window of AutoIt, showing more details about the error, including ability to save and send by email! (Detection and treatment of errors in the AutoIt scripts!) Sintax: ; Adding the directives below, will cause your program be compiled with the indexing of the original lines shown in SciTE: #AutoIt3Wrapper_Run_Before=ShowOriginalLine.exe %in% #AutoIt3Wrapper_Run_After=ShowOriginalLine.exe %in% ;Or you can use the program "ShowOriginalLine.exe" directly and choose the script you want to add support to show the original lines! #include "_AutoItErrorTrap.au3" ; _AutoItErrorTrap ([sTitle [, sText [, fUseCallBack]]]) _AutoItErrorTrap()Supports: ;Error detection in your AutoIt script and local #Includes! ;According to the AutoIt Help, the definition for "local Includes" is: ;------------------------------------------------------------------------------ ;If "..." is used, the filename is taken to be relative to the current script. ;------------------------------------------------------------------------------ ;This means that for you to have your UDF or other external module with support to show the original lines, one should use as follows: #include "[path] filename" ; See the AutoIt help for more details.Downloads: Version: 0.11 _AutoItErrorTrap_(RedirectLink).html Note: The error detection is performed in the same executable, does not requiring opening two .exes for this action! Works with CUI too. Usage example is included! (You need to compile first, but it also work with non compiled scripts using context menu [Run Script...]) Sample: More sample: Fixes: #ShowLine_Off $hForm = GUICreate("My GUI menu", 480, 360) $iFileMenu = GUICtrlCreateMenu("&File") $iFileItem = GUICtrlCreateMenuItem("Open", $iFileMenu) GUICtrlSetState(-1, $GUI_DEFBUTTON) $iHelpMenu = GUICtrlCreateMenu("?") GUICtrlCreateMenuItem("Save", $iFileMenu) GUICtrlSetState(-1, $GUI_DISABLE) #ShowLine_OnWithout them the rows above would be as follows: $__iLineNumber=1 & " - " & '$hForm = GUICreate("My GUI menu", 480, 360)...' $hForm = GUICreate("My GUI menu", 480, 360) $__iLineNumber=3 & " - " & '$iFileMenu = GUICtrlCreateMenu("&File")' $iFileMenu = GUICtrlCreateMenu("&File") $__iLineNumber=4 & " - " & '$iFileItem = GUICtrlCreateMenuItem("Ope...' $iFileItem = GUICtrlCreateMenuItem("Open", $iFileMenu) $__iLineNumber=5 & " - " & 'GUICtrlSetState(-1, $GUI_DEFBUTTON)' GUICtrlSetState(-1, $GUI_DEFBUTTON) $__iLineNumber=6 & " - " & '$iHelpMenu = GUICtrlCreateMenu("?")' $iHelpMenu = GUICtrlCreateMenu("?") $__iLineNumber=7 & " - " & 'GUICtrlCreateMenuItem("Save", $iFileMenu)' GUICtrlCreateMenuItem("Save", $iFileMenu) $__iLineNumber=8 & " - " & 'GUICtrlSetState(-1, $GUI_DISABLE)' GUICtrlSetState(-1, $GUI_DISABLE) And the directive #ShowOriginalLine_Param with the following options: /SV or /SkipAllVars ; Skip all Variables to show original line numbers. /SG or /SkipGlobalVars ; Skip Global Variables to show original line numbers. /SL or /SkipLocalVars ; Skip Local Variables to show original line numbers.29/10/2012 -> *Adding the directives below, will cause your program be compiled with the indexing of the original lines shown in SciTE: #AutoIt3Wrapper_Run_Before=ShowOriginalLine.exe %in% #AutoIt3Wrapper_Run_After=ShowOriginalLine.exe %in%*Or you can use the program ShowOriginalLine.exe directly and choose the script you want to add support to show the original lines!*It was added #region Translations with the variables available for translation! 0.10.2312.2600b 25/10/2012 -> Added support for viewing the last screen before the error! Now the window can expand and retract again...Change the hook CALLWNDRETPROC to CALLWNDPROC (better...). Added a help button [?] In the main window and minor changes in the code. 0.10.2312.2600b 23/10/2012 -> *Added support to display the original line numbers in the scripts compiled! Thanks to @FireFox for this tip! $hAET_GETERROR = StringRegExpReplace($hAET_GETERROR, "d+[0-9]", Eval("__iLineNumber") & @CRLF)*Additional information suggested by @ricky03, thank you!*Some bugs were fixed and the file ShowOriginalLineNumbers.au3 was added in zip file. 0.10.2112.2600b 21/10/2012 -> Bugs were fixed and a few functions have been rewritten!0.10.1912.2600b 19/10/2012 -> The UDF was almost completely rewritten, now no longer need to include _AdlibEnhance.au3.The detection of error is instant and does not consume more CPU. Interface compatibility with Windows XP 0.10.1812.2600b 18/10/2012 -> Improvements such as icons on the buttons and added a button to save the error information!0.10.1712.2600b 17/10/2012 -> First release!Regards, João Carlos.1 point -
INI File Processing Functions
toasterking reacted to DXRW4E for a topic
IniEx.au3 (INI File Processing Functions) solve many problems, such as the limits of AutoIt Default INI function, and add many other options, since all function work by reference so IniEx.au3 also use less memory, and provide a really good performance in speed #include-Once ; #INDEX# ======================================================================================================================= ; Title .........: IniEx ; AutoIt Version : v3.3.9.22++ ; Language ......: English ; Description ...: INI File Processing Functions ; Author(s) .....: DXRW4E ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ;_IniClearCache() ;_IniCloseFileEx() ;_IniDeleteEx() ;_IniFileWriteEx() ;_IniGetFileInformationEx() ;_IniGetFileStringData() ;_IniGetSectionNumberEx() ;_IniOpenFileEx() ;_IniOpenFile() ;_IniReadEx() ;_IniReadSectionEx() ;_IniReadSectionNamesEx() ;_IniRenameSectionEx() ;_IniWriteEx() ;_IniWriteSectionEx() ; =============================================================================================================================== ; #INTERNAL_USE_ONLY# =========================================================================================================== ;__GetSeparatorCharacter() ;__IniFileWriteEx() ;__IniGetFileStringData() ;__IniReadSectionEx() ;__IniSaveCache() ;__IniWriteSectionEx() ; =============================================================================================================================== ; #CONSTANTS# =================================================================================================================== Global Const $INI_STRIPLEADING = 1 ; $STR_STRIPLEADING - strip leading white space Global Const $INI_STRIPTRAILING = 2 ; $STR_STRIPTRAILING - strip trailing white space Global Const $INI_STRIPLEADTRAILING = 3 ; BitOR($STR_STRIPLEADING, $STR_STRIPTRAILING) Global Const $INI_ARRAYDATA = 4 Global Const $INI_ARRAYDATA_NOCOUNT = 8 Global Const $INI_NOWRITEREADONLY = 16 Global Const $INI_FO_UNICODE = 32 ; $FO_UNICODE Global Const $INI_FO_UTF16_LE = 32 ; $FO_UTF16_LE Global Const $INI_FO_UTF16_BE = 64 ; $FO_UTF16_BE Global Const $INI_FO_UTF8 = 128 ; $FO_UTF8 Global Const $INI_FO_UTF8_NOBOM = 256 ; $FO_UTF8_NOBOM Global Const $INI_NOOCCURRENCE = 512 Global Const $INI_MERGE = 1024 Global Const $INI_NOCREATE = 2048 Global Const $INI_APPENDDATA = 4096 Global Const $INI_REPLACEONLY = 8192 Global Const $INI_FO_UTF8_FULL = 16384 ; $FO_UTF8_FULL Global Const $INI_NOOVERWRITE = 32768 Global Const $INI_OVERWRITEALL = 65536 Global Const $INI_IGNOREDUPLICATE = 131072 Global Const $INI_DELETE = 262144 Global Const $INI_RENAME = 524288 Global Const $INI_REMOVE = 1048576 ;Global Const $INI_RESERVED* = 2097152 ;Global Const $INI_RESERVED* = 4194304 ;Global Const $INI_RESERVED* = 8388608 Global Const $INI_OPEN_EXISTING = 16777216 Global Const $INI_CREATEPATH = 33554432 Global Const $INI_REPAIR_ERROR = 67108864 Global Const $INI_DISCARDCHANGES = 134217728 Global Const $INI_OPEN_FILEQUEUE = 268435456 ;Global Const $INI_RESERVED* = 536870912 Global Const $INI_2DARRAYFIELD = 1073741824 ;;;; THESE ARE SPECIAL FLAGS, ARE USED INTERNALLY ONLY ;;;; Global Const $INI_INTERNAL_USE_ONLY = 2147483648 Global Const $INI_FO_STYLE = BitOR(31, $INI_OPEN_EXISTING, $INI_CREATEPATH, $INI_REPAIR_ERROR, $INI_OPEN_FILEQUEUE) Global Const $INI_MERGE_NOOCCURRENCE = BitOR($INI_MERGE, $INI_NOOCCURRENCE) Global Const $INI_REMOVE_RENAME = BitOR($INI_REMOVE, $INI_RENAME) Global Const $INI_REMOVE_DELETE = BitOR($INI_REMOVE, $INI_DELETE) Global Const $INI_NOCREATE_REMOVE_DELETE = BitOR($INI_NOCREATE, $INI_REMOVE, $INI_DELETE) Global Const $INI_NOOCCURRENCE_IGNOREDUPLICATE = BitOr($INI_NOOCCURRENCE, $INI_IGNOREDUPLICATE) Global Const $INI_OVERWRITEALL_APPENDDATA = BitOR($INI_OVERWRITEALL, $INI_APPENDDATA) Global Const $NULL_REF = Null Global Const $sINI_OPENFILE_EX = @LF & "[]" & @LF ;;;; DO NOT EVER USE\CHANGE\EDIT THESE VARIABLES ;;;; ;;;; THESE VARIABLES ARE USED INTERNALLY ONLY ;;;; Global Static $INI_NULL_REF = Null Global Static $_HINI[11][11] = [[10, 0]] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniOpenFileEx ; Description ...: The _IniOpenFileEx function opens an INI file and returns a handle to it. ; Syntax.........: _IniOpenFileEx($sFilePath[, $iFlags]]) ; Parameters ....: $sFilePath - INI File Path ; $iFlags - Optional, (add the flags together for multiple operations): ; This Flags will be ignored if the $INI_CREATEPATH is not set\used ; | A file may fail to open due to access rights or attributes. ; | The default mode when writing text is ANSI - use the unicode flags to change this. When writing unicode files ; | the Windows default mode (and the fastest in AutoIt due to the least conversion) is UTF16 Little Endian (mode 32). ; | $INI_FO_* Flags will be ignored if the $INI_CREATEPATH is not Set\Used ; |$INI_FO_UNICODE or $INI_UTF16_LE (32) - Use Unicode UTF16 Little Endian reading and writing mode. Reading does not override existing BOM. ; |$INI_FO_UTF16_BE (64) - Use Unicode UTF16 Big Endian reading and writing mode. Reading does not override existing BOM. ; |$INI_FO_UTF8 (128) - Use Unicode UTF8 (with BOM) reading and writing mode. Reading does not override existing BOM. ; |$INI_FO_UTF8_NOBOM (256) - Use Unicode UTF8 (without BOM) reading and writing mode. ; |$INI_FO_UTF8_FULL (16384) - When opening for reading and no BOM is present, use full file UTF8 detection. If this is not used then only the initial part of the file is checked for UTF8. ; ;;;;;;;;;;;; ; |$INI_OPEN_EXISTING (16777216) - If the INI File (Path) is Already Open use that (Handle) (Default Always Opens a New) ; |$INI_CREATEPATH (33554432) - Create INI File if does not exist (Default if file not exist Return Error) ; |$INI_REPAIR_ERROR (67108864) - If exist Error when Opening the INI File Repair Error, example as this line (@CRLF & [SectionName & @CRLF) repair in (@CRLF & [SectionName] & @CRLF), Default Return Error ; |$INI_OPEN_FILEQUEUE (268435456) - Open INI file from Memory\Variable, $sFilePath must contain String Text Data of INI file ; Return values .: Success - INI Handle ; Failure - Returns 0 or String\Text of error line (check @Extended for error line number) ; @Error - 0 = No error. ; |1 = File cannot be opened or found. ; |2 = Error when Opening the INI File ; Remarks .......: ; Author ........: DXRW4E ; =============================================================================================================================== Func _IniOpenFileEx($sFilePath, $iFlags = 0) If BitAND($iFlags, $INI_OPEN_EXISTING) Then For $i = 1 To $_HINI[0][0] If $_HINI[$i][2] = $sFilePath Then Return SetError(0, $i, $i) Next EndIf Local $sCS, $_sCS = "\r", $hFilePath, $iFileEncoding, $aFileData, $aErrorLine, $iFO_Style = BitXOR(BitOR($iFlags, $INI_FO_STYLE), $INI_FO_STYLE) If BitAND($iFlags, $INI_OPEN_FILEQUEUE) Then $aFileData = StringRegExpReplace($sINI_OPENFILE_EX & $sFilePath, '\r(?!\n)', @CRLF) ;;;;, '(?<!\r)\n', @CRLF) $sFilePath = "FileQueue" $iFileEncoding = $iFO_Style ;;(StringIsASCII($aFileData) ? 0 : 32) Else $hFilePath = FileOpen($sFilePath) If $hFilePath = -1 Then If Not FileExists($sFilePath) Then If Not BitAND($iFlags, $INI_CREATEPATH) Then Return SetError(1, 0, 0) $iFO_Style += 10 ;;$iFO_Style = 42 EndIf $hFilePath = FileOpen($sFilePath, $iFO_Style) If $hFilePath = -1 Then Return SetError(1, 0, 0) EndIf $aFileData = StringRegExpReplace($sINI_OPENFILE_EX & FileRead($hFilePath), '\r(?!\n)', @CRLF) ;;;;, '(?<!\r)\n', @CRLF) $iFileEncoding = FileGetEncoding($hFilePath) FileClose($hFilePath) EndIf $aErrorLine = StringRegExp($aFileData, '\n\K[\h\f\xb\x0]*\[[^\]\n]*(?:\n|$)', 1) If Not @Error Then Local $iErrorLine = @Extended - (StringLen($aErrorLine[0]) - 1) If Not BitAND($iFlags, $INI_REPAIR_ERROR) Then Return SetError(2, StringSplit(StringLeft($aFileData, $iErrorLine), @LF)[0] - 2, $aErrorLine[0]) $aFileData = StringRegExpReplace($aFileData, '(\n[\h\f\xb\x0]*\[[^\]\r\n]*)(?=[\r\n]|$)', "$1]") EndIf $sCS = __GetSeparatorCharacter($aFileData) If $sCS = @CR Then $_sCS = "" $aFileData = StringRegExpReplace($aFileData & @CRLF & "[", "\n\K(?>[" & $_sCS & "\n\h\f\xb\x0]*\n|\x0*)(?=[\h\f\xb\x0]*\[)", $sCS & "${0}" & $sCS) $aFileData = StringRegExp($aFileData & $sCS, $sCS & "([\h\f\xb\x0]*\[)([^\]\n]*)(\][^\n]*\n)((?>[" & $_sCS & "\n\h\f\xb\x0]*\n)*)([^" & $sCS & "]*)" & $sCS & "([^" & $sCS & "]*)", 3) $aFileData[0] = UBound($aFileData) - 1 If $aFileData[0] < 5 Then Return SetError(1, 0, 0) ; should not happen ever $aFileData[$aFileData[0]] = StringTrimRight($aFileData[$aFileData[0]], 2) For $iHINI = 1 To $_HINI[0][0] If Not $_HINI[$iHINI][0] Then ExitLoop Next If $iHINI > $_HINI[0][0] Then ReDim $_HINI[$iHINI + $iHINI][11] $_HINI[0][0] = $iHINI + $iHINI - 1 EndIf $aFileData[2] = $iHINI If Not $_sCS Then $aFileData[3] = StringAddCR($aFileData[3]) $aFileData[4] = StringAddCR($aFileData[4]) $aFileData[5] = StringAddCR($aFileData[5]) EndIf For $i = 7 To $aFileData[0] Step 6 $_HINI[$iHINI][5] &= @LF & $aFileData[$i] & @CR & $i If Not $_sCS Then $aFileData[$i + 1] = StringAddCR($aFileData[$i + 1]) $aFileData[$i + 2] = StringAddCR($aFileData[$i + 2]) $aFileData[$i + 3] = StringAddCR($aFileData[$i + 3]) $aFileData[$i + 4] = StringAddCR($aFileData[$i + 4]) EndIf Next $_HINI[0][1] += 1 ;;($_HINI[0][1] < 1) ? 1 : $_HINI[0][1] + 1 $_HINI[$iHINI][0] = $iHINI $_HINI[$iHINI][1] = $aFileData $_HINI[$iHINI][2] = $sFilePath $_HINI[$iHINI][3] = $iFileEncoding $_HINI[$iHINI][4] = ($aFileData[0] - 5) / 6 $_HINI[$iHINI][5] = StringReplace($_HINI[$iHINI][5], "\E", "\e", 0, 1) $_HINI[$iHINI][7] = Null Return $iHINI EndFunc ;==>_IniOpenFileEx ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniOpenFile ; Description ...: The _IniOpenFile function opens an INI file and returns a handle to it. ; Parameters ....: the same as the _IniOpenFileEx(), See _IniOpenFileEx() ; Return values .: See _IniOpenFileEx() ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: _IniOpenFile() is the same as the _IniOpenFileEx(), only that _IniOpenFile() force the check\repair of @CR or @LF in @CRLF ; performance\speed does not change much with _IniOpenFileEx(), _IniOpenFile() can only be about 1% or 5% or10% slower ; =============================================================================================================================== Func _IniOpenFile($sFilePath, $iFlags = 0) If BitAND($iFlags, $INI_OPEN_EXISTING) Then For $i = 1 To $_HINI[0][0] If $_HINI[$i][2] = $sFilePath Then Return SetError(0, $i, $i) Next EndIf Local $hFilePath, $iFileEncoding, $aFileData, $aErrorLine, $iFO_Style = BitXOR(BitOR($iFlags, $INI_FO_STYLE), $INI_FO_STYLE) If BitAND($iFlags, $INI_OPEN_FILEQUEUE) Then $aFileData = StringRegExpReplace($sINI_OPENFILE_EX & $sFilePath, '\r\n?', @LF) $sFilePath = "FileQueue" $iFileEncoding = $iFO_Style ;;(StringIsASCII($aFileData) ? 0 : 32) Else $hFilePath = FileOpen($sFilePath) If $hFilePath = -1 Then If Not FileExists($sFilePath) Then If Not BitAND($iFlags, $INI_CREATEPATH) Then Return SetError(1, 0, 0) $iFO_Style += 10 ;;$iFO_Style = 42 EndIf $hFilePath = FileOpen($sFilePath, $iFO_Style) If $hFilePath = -1 Then Return SetError(1, 0, 0) EndIf $aFileData = StringRegExpReplace($sINI_OPENFILE_EX & FileRead($hFilePath), '\r\n?', @LF) $iFileEncoding = FileGetEncoding($hFilePath) FileClose($hFilePath) EndIf $aErrorLine = StringRegExp($aFileData, '\n\K[\h\f\xb\x0]*\[[^\]\n]*(?:\n|$)', 1) If Not @Error Then Local $iErrorLine = @Extended - (StringLen($aErrorLine[0]) - 1) If Not BitAND($iFlags, $INI_REPAIR_ERROR) Then Return SetError(2, StringSplit(StringLeft($aFileData, $iErrorLine), @LF)[0] - 2, $aErrorLine[0]) $aFileData = StringRegExpReplace($aFileData, '(\n[\h\f\xb\x0]*\[[^\]\n]*)(?=\n|$)', "$1]") EndIf $aFileData = StringRegExpReplace($aFileData & @LF & "[", '\n\K(?>[\n\h\f\xb\x0]*\n|\x0*)(?=[\h\f\xb\x0]*\[)', @CR & "${0}" & @CR) $aFileData = StringRegExp($aFileData & @CR, '\r([\h\f\xb\x0]*\[)([^\]\n]*)(\][^\n]*\n)((?>[\n\h\f\xb\x0]*\n)*)([^\r]*)\r([^\r]*)', 3) $aFileData[0] = UBound($aFileData) - 1 If $aFileData[0] < 5 Then Return SetError(1, 0, 0) ; should not happen ever $aFileData[$aFileData[0]] = StringTrimRight($aFileData[$aFileData[0]], 1) For $iHINI = 1 To $_HINI[0][0] If Not $_HINI[$iHINI][0] Then ExitLoop Next If $iHINI > $_HINI[0][0] Then ReDim $_HINI[$iHINI + $iHINI][11] $_HINI[0][0] = $iHINI + $iHINI - 1 EndIf $aFileData[2] = $iHINI $aFileData[3] = StringAddCR($aFileData[3]) $aFileData[4] = StringAddCR($aFileData[4]) $aFileData[5] = StringAddCR($aFileData[5]) For $i = 7 To $aFileData[0] Step 6 $_HINI[$iHINI][5] &= @LF & $aFileData[$i] & @CR & $i $aFileData[$i + 1] = StringAddCR($aFileData[$i + 1]) $aFileData[$i + 2] = StringAddCR($aFileData[$i + 2]) $aFileData[$i + 3] = StringAddCR($aFileData[$i + 3]) $aFileData[$i + 4] = StringAddCR($aFileData[$i + 4]) Next $_HINI[0][1] += 1 ;;($_HINI[0][1] < 1) ? 1 : $_HINI[0][1] + 1 $_HINI[$iHINI][0] = $iHINI $_HINI[$iHINI][1] = $aFileData $_HINI[$iHINI][2] = $sFilePath $_HINI[$iHINI][3] = $iFileEncoding $_HINI[$iHINI][4] = ($aFileData[0] - 5) / 6 $_HINI[$iHINI][5] = StringReplace($_HINI[$iHINI][5], "\E", "\e", 0, 1) $_HINI[$iHINI][7] = Null Return $iHINI EndFunc ;==>_IniOpenFileEx ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniCloseFileEx ; Description ...: The _IniCloseFileEx function closes the INI file opened by a call to _IniOpenFileEx. ; Syntax.........: _IniCloseFileEx($hIniFile[, $iFlags]) ; Parameters ....: $hIniFile - Handle or INI Path to the INI file to be closed, This parameter can be NULL (use the $NULL_REF to set NULL this parameter) ; if $hIniFile is NULL Function Close All Open Handle or INI Path ; $iFlags - Optional, Flag to indicate the type of action that should be performed (add the flags together for multiple operations): ; |Default - always Commits the changes that were made when the INI file was opened by _IniOpenFileEx() ; |$INI_DISCARDCHANGES (134217728) - Discards the changes that were made when the INI file was opened by _IniOpenFileEx() ; Return values .: NONE ; Author ........: DXRW4E ; Remarks .......: ; =============================================================================================================================== Func _IniCloseFileEx($hIniFile, $iFlags = 0) If $hIniFile = $NULL_REF Then For $i = 1 To $_HINI[0][0] If Not BitAND($iFlags, $INI_DISCARDCHANGES) And $_HINI[$i][2] <> "FileQueue" Then _IniFileWriteEx($i, $iFlags) For $y = 0 To 10 $_HINI[$i][$y] = "" Next Next $_HINI[0][1] = 0 Else $hIniFile = _IniGetFileInformationEx($hIniFile) If @Error Then Return SetError(1, 0, 0) If Not BitAND($iFlags, $INI_DISCARDCHANGES) And $_HINI[$hIniFile][2] <> "FileQueue" Then _IniFileWriteEx($hIniFile, $iFlags) For $i = 0 To 10 $_HINI[$hIniFile][$i] = "" Next $_HINI[0][1] -= 1 EndIf Return 0 EndFunc ;==>_IniCloseFileEx ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniDeleteEx ; Description ...: Delete\Remove - Section\KeyName in INI File. ; Syntax.........: _IniDeleteEx(ByRef $hIniFile, $sSectionName[, $sKeyName[, $iFlags[, $scKeyName]]]) ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; $sSectionName - The name of the section containing the Key\Value, This parameter can be NULL (use the $NULL_REF to set NULL this parameter) ; If $sSectionName is NULL, $hIniFile must be contain Section String\Key\Value\Data and $sKeyName the name of the key to delete ; $sKeyName - The key name to delete, If $INI_OVERWRITEALL if set\used, $sKeyName will be writte exactly as in $sKeyName (without Edit\Formatting) ; This parameter can be NULL (use the $NULL_REF to set NULL this parameter), If $sKeyName is NULL, $hIniFile must be contain INI String\Text Data and $sSectionName the name of the section to delete ; $iFlags - Optional, Flag to indicate the type of action that should be performed (add the flags together for multiple operations): ; |$INI_NOOCCURRENCE (512) - Check only first section if there are more than one ; |$INI_IGNOREDUPLICATE (131072) - Proceed\Execute (Add\Delete\Replace\Edit ect ect) Once Only (Ignore all other Duplicate\Occurrences of KeyName\Value\Data) ; |$INI_DELETE (262144) - Delete\Remove KeyName\Value\Data ; |$INI_REMOVE (1048576) - Remove\Delete Section ; $scKeyName - Optional, Key-Name separator character, Default is '=', This parameter can not be '"' or @CR or @LF ; Return values .: Returns a 0 (check @Extended for number of edit performed) ; @Error - 0 = No error. ; |1 = Invalid IniHandle. ; |3 = SectionName not found ; Remarks .......: $INI_MERGE (1024) - (Join section if more than one in INI file) is always set\used by default, to disable it just use the $INI_NOOCCURRENCE ; Author ........: DXRW4E ; =============================================================================================================================== Func _IniDeleteEx(ByRef $hIniFile, $sSectionName, $sKeyName = "", $iFlags = 0, $scKeyName = "=") If Not $scKeyName Then $scKeyName = "=" If $sSectionName = $NULL_REF Then Local $iOffSet = StringInStr($hIniFile, @LF, 1) If StringRegExp(StringLeft($hIniFile, $iOffSet), '^(?i)[\h\f\xb\x0]*(?>\Q"' & $sKeyName & '"\E|\Q' & $sKeyName & '\E)[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*[^\n]*') Then If Not BitAND($iFlags, $INI_IGNOREDUPLICATE) Then $hIniFile = StringRegExpReplace($hIniFile, '\n[\h\f\xb\x0]*(?i)(?>\Q"' & $sKeyName & '"\E|\Q' & $sKeyName & '\E)[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*[^\n]*', "") $hIniFile = StringTrimLeft($hIniFile, $iOffSet) SetExtended(1) Else $hIniFile = StringRegExpReplace($hIniFile, '\n[\h\f\xb\x0]*(?i)(?>\Q"' & $sKeyName & '"\E|\Q' & $sKeyName & '\E)[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*[^\n]*', "", (BitAND($iFlags, $INI_IGNOREDUPLICATE) ? 1 : 0)) EndIf ElseIf $sKeyName = $NULL_REF Then ;Not Recommended (NOT SAFE), if the Section (contains) String\Text Data is greater than 4.5 MB, the Section will be ignored $hIniFile = StringTrimRight(StringRegExpReplace($hIniFile & @LF & "[", "(?is)\n[\h\f\xb\x0]*\[\Q" & StringReplace($sSectionName, "\E", "\e", 0, 1) & "\E\][^\n]*(?>\n?(?![\h\f\xb\x0]*\[))(.*?(?=\n[\h\f\xb\x0]*\[))", "", (BitAND($iFlags, $INI_IGNOREDUPLICATE) ? 1 : 0)), 2) Else If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Return SetError(1, 0, "") ;;;;If Not $sSectionName Then Return SetError(2, 0, "") ;Invalid Section Name If StringInStr($sSectionName, "\E", 1) Then $sSectionName = StringReplace($sSectionName, "\E", "\e", 0, 1) If Not $sKeyName Or BitAND($iFlags, $INI_REMOVE_DELETE) = $INI_REMOVE Then $iFlags = BitOr($iFlags, $INI_REMOVE) __IniWriteSectionEx($hIniFile, $sSectionName, $INI_NULL_REF, $iFlags, $INI_NULL_REF, $_HINI[$hIniFile][1]) Else $iFlags = BitOR(BitAND($iFlags, $INI_NOOCCURRENCE_IGNOREDUPLICATE), $INI_DELETE, $INI_MERGE) If $_HINI[$hIniFile][7] <> $sSectionName Or ($_HINI[$hIniFile][8] > 1 And BitAND($iFlags, $INI_MERGE_NOOCCURRENCE) <> BitAND($_HINI[$hIniFile][9], $INI_MERGE_NOOCCURRENCE)) Then __IniReadSectionEx($hIniFile, $sSectionName, $iFlags, $_HINI[$hIniFile][1]) If @Error Then Return SetError(3, 0, "") EndIf Local $aKeyValue[2][3] = [[1],[$sKeyName]] __IniWriteSectionEx($hIniFile, $sSectionName, $aKeyValue, $iFlags, $scKeyName, $_HINI[$hIniFile][1]) EndIf EndIf Return SetError(0, @Extended, 0) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniReadEx ; Description ...: The _IniReadEx Retrieves a string from the specified section in an Ini file ; Syntax.........: _IniReadEx($hIniFile, $sSectionName, $sKeyName[, $sDefault[, $iFlags[, $scKeyName]]]) ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; $sSectionName - The name of the section containing the key name, This parameter can be NULL (use the $NULL_REF to set NULL this parameter) ; If $sSectionName is NULL, $hIniFile must be contain Section String\Key\Value\Data ; $sKeyName - The name of the key whose associated string is to be retrieved ; $sDefault - The default value to return if the requested KeyName is not found. ; $iFlags - Optional, Flag to indicate the type of action that should be performed (add the flags together for multiple operations): ; |$INI_ARRAYDATA (4) - Read All KeyName and Return Array of ValueString ; |$INI_ARRAYDATA_NOCOUNT (8) - Disable the return count in the first element, This Flags will be ignored if the $INI_ARRAYDATA is not set\used ; |$INI_NOOCCURRENCE (512) - Read only first section if there are more than one ; |$INI_MERGE (1024) - Join section if more than one in INI file, This Flag will be ignored if the $INI_NOOCCURRENCE is set\used ; $scKeyName - Optional, Key-Name separator character, Default is '=', This parameter can not be '"' or @CR or @LF ; Return values .: The first occurrence of requested key value as a string Or Array of Value String ; Failure - Returns $sDefault parameter ; @Error - 0 = No error. ; |1 = Invalid IniHandle. ; |3 = SectionName not found ; |5 = Invalid KeyName ; |6 = KeyName not found ; Remarks .......: ; Author ........: DXRW4E ; =============================================================================================================================== Func _IniReadEx(ByRef $hIniFile, $sSectionName, $sKeyName, $sDefault = "", $iFlags = 0, $scKeyName = "=") ;;If Not $sKeyName Then Return SetError(5, 0, "") If StringInStr($sKeyName, "\E", 1) Then $sKeyName = StringReplace($sKeyName, "\E", "\e", 0, 1) Local $aValueString, $sValueString, $iArray = BitAND($iFlags, $INI_ARRAYDATA) If $sSectionName = $NULL_REF Then $aValueString = StringRegExp(StringLeft($hIniFile, StringInStr($hIniFile, @LF, 1)), '^(?i)[\h\f\xb\x0]*(?>\Q"' & $sKeyName & '"\E|\Q' & $sKeyName & '\E)(?>[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*)(?|"([^\r\n]*)"|(.*?))[\h\f\xb\x0]*(?=[\r\n]|$)', 1) Else If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Return SetError(1, 0, "") If StringInStr($sSectionName, "\E", 1) Then $sSectionName = StringReplace($sSectionName, "\E", "\e", 0, 1) If $_HINI[$hIniFile][7] <> $sSectionName Or ($_HINI[$hIniFile][8] > 1 And BitAND($iFlags, $INI_MERGE_NOOCCURRENCE) <> BitAND($_HINI[$hIniFile][9], $INI_MERGE_NOOCCURRENCE)) Then _IniReadSectionEx($hIniFile, $sSectionName, BitOR($iFlags, $INI_STRIPLEADTRAILING)) If @Error Then Return SetError(3, 0, "") EndIf $aValueString = StringRegExp(StringLeft(($_HINI[$hIniFile][1])[$_HINI[$hIniFile][10]], StringInStr(($_HINI[$hIniFile][1])[$_HINI[$hIniFile][10]], @LF, 1)), '^(?i)[\h\f\xb\x0]*(?>\Q"' & $sKeyName & '"\E|\Q' & $sKeyName & '\E)(?>[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*)(?|"([^\r\n]*)"|(.*?))[\h\f\xb\x0]*(?=[\r\n]|$)', 1) ;;;;$aValueString = StringRegExp(($sSectionName = $NULL_REF ? $hIniFile : ($_HINI[$hIniFile][1])[$_HINI[$hIniFile][10]]), '(?im)^[\h\f\xb\x0]*(?>\Q"' & $sKeyName & '"\E|\Q' & $sKeyName & '\E)[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*(?|"([^\r\n]*)"|(.*?))[\h\f\xb\x0]*(?=[\r\n]|$)', 3) EndIf If Not @Error Then If Not $iArray Then Return $aValueString[0] $sValueString = $aValueString[0] & @LF EndIf $aValueString = StringRegExp(($sSectionName = $NULL_REF ? $hIniFile : ($_HINI[$hIniFile][1])[$_HINI[$hIniFile][10]]), '\n[\h\f\xb\x0]*(?i)(?>\Q"' & $sKeyName & '"\E|\Q' & $sKeyName & '\E)(?>[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*)(?|"([^\r\n]*)"|(.*?))[\h\f\xb\x0]*(?=[\r\n]|$)', ($iArray ? 3 : 1)) If @Error Then Return SetError(6, 0, $sDefault) If Not $iArray Then Return $aValueString[0] For $i = 0 To UBound($aValueString) - 1 $sValueString &= $aValueString[$i] & @LF Next Return StringSplit(StringTrimRight($sValueString, 1), @LF, (BitAND($iFlags, $INI_ARRAYDATA_NOCOUNT) ? 3 : 1)) EndFunc ;==>_IniReadEx ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniReadSectionEx ; Description ...: The _IniReadSectionEx Retrieves all the lines for the specified section ; Syntax.........: _IniReadSectionEx(ByRef $hIniFile, $sSectionName[, $iFlags[, $scKeyName]) ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; $sSectionName - The name of the section containing the Key\Value, This parameter can be NULL (use the $NULL_REF to set NULL this parameter) ; If $sSectionName is NULL, $hIniFile must be contain Section String\Key\Value\Data ; $iFlags - Optional, Flag to indicate the type of action that should be performed (add the flags together for multiple operations): ; Default Return Section String\Text Data ; |$INI_NOOCCURRENCE (512) - Read only first section if there are more than one ; |$INI_MERGE (1024) - Join section if more than one in INI file, This Flag will be ignored if the $INI_NOOCCURRENCE is set\used ; |$INI_2DARRAYFIELD (1073741824) - Return 2DArray ; $aArray[0][0] = number of elements ; $aArray[0][1] = Key-Name separator character, Defaut is '=' ; $aArray[1][0] = "KeyName" ; $aArray[1][1] = "Value" ; $aArray[1][2] = "Unmodified contents of a line (example ' KeyName = Value')" ; $aArray[n][0] = "KeyName" ; $aArray[n][1] = "Value" ; $aArray[n][2] = "Unmodified contents of a line (example ' KeyName = Value')" ; $scKeyName - Optional, Key-Name separator character, Default is '=', This parameter can not be '"' or @CR or @LF ; Return values .: String\Text Data Or 2D Array ; @Error - 0 = No error. ; |1 = Invalid IniHandle. ; |3 = SectionName's not found ; |4 = Array is invalid, Key\Value not found ; Remarks .......: ; Author ........: DXRW4E ; =============================================================================================================================== Func _IniReadSectionEx(ByRef $hIniFile, $sSectionName, $iFlags = 0, $scKeyName = "=") If Not $scKeyName Then $scKeyName = "=" If $sSectionName = $NULL_REF Then Local $_aSectionData = StringRegExp($hIniFile, '(?m)^((?>[\h\f\xb\x0]*)((?>"[^"\r\n]+"|(?:[^"\s' & $scKeyName & '\x0]+|(?>[\h\f\xb\x0]+)(?!' & $scKeyName & '))*))(?>[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*)(?|"([^\r\n]*)"|(.*?))[\h\f\xb\x0]*(?=[\r\n]|$))', 3) Else If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Return SetError(1, 0, "") If $_HINI[$hIniFile][7] <> $sSectionName Or ($_HINI[$hIniFile][8] > 1 And BitAND($iFlags, $INI_MERGE_NOOCCURRENCE) <> BitAND($_HINI[$hIniFile][9], $INI_MERGE_NOOCCURRENCE)) Then $iFlags = BitOR($iFlags, $INI_NOCREATE) __IniReadSectionEx($hIniFile, $sSectionName, $iFlags, $_HINI[$hIniFile][1]) If @Error Then Return SetError(3, 0, "") EndIf If Not BitAND($iFlags, $INI_2DARRAYFIELD) Then Return ($_HINI[$hIniFile][1])[$_HINI[$hIniFile][10]] Local $_aSectionData = StringRegExp(($_HINI[$hIniFile][1])[$_HINI[$hIniFile][10]], '(?m)^((?>[\h\f\xb\x0]*)((?>"[^"\r\n]+"|(?:[^"\s' & $scKeyName & '\x0]+|(?>[\h\f\xb\x0]+)(?!' & $scKeyName & '))*))(?>[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*)(?|"([^\r\n]*)"|(.*?))[\h\f\xb\x0]*(?=[\r\n]|$))', 3) EndIf If @Error Then Return SetError(4, 0, "") Local $iaSectionData = UBound($_aSectionData), $aSectionData[$iaSectionData / 3 + 1][3] = [[0,$scKeyName,$iaSectionData - 1]] For $i = 0 To $aSectionData[0][2] Step 3 $aSectionData[0][0] += 1 $aSectionData[$aSectionData[0][0]][0] = $_aSectionData[$i + 1] $aSectionData[$aSectionData[0][0]][1] = $_aSectionData[$i + 2] $aSectionData[$aSectionData[0][0]][2] = $_aSectionData[$i] Next Return SetError(0, $aSectionData[0][0], $aSectionData) EndFunc ;==>_IniReadSectionEx ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniReadSectionNamesEx ; Description ...: The _IniReadSectionNamesEx Retrieves the names of all sections in an INI file ; Syntax.........: _IniReadSectionNamesEx($hIniFile[, $iFlags]) ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; $iFlags - Optional, Flag to indicate the type of action that should be performed ; |$INI_ARRAYDATA_NOCOUNT (8) - disable the return count in the first element ; |$NULL_REF (NULL) - $hIniFile must be contain INI String\Section\Key\Value\Data ; Return values .: Array of SectionNames String, and set @Extended = Number of Section's ; @Error - 0 = No error. ; |1 = Array is invalid, Invalid IniHandle. ; |3 = Array is invalid, SectionName's not found ; Remarks .......: ; Author ........: DXRW4E ; =============================================================================================================================== Func _IniReadSectionNamesEx(ByRef $hIniFile, $iFlags = 0) If $iFlags = $NULL_REF Then Local $aSectionNames, $iANC = BitAND($iFlags, $INI_ARRAYDATA_NOCOUNT) $aSectionNames = StringRegExp(($iANC ? @LF : @LF & "[]" & @LF) & $hIniFile, "\n[\h\f\xb\x0]*\[([^\r\n]*)\]", 3) If @Error Then Return SetError(1, 0, "") If $iANC Then Return SetError(0, UBound($aSectionNames), $aSectionNames) $aSectionNames[0] = UBound($aSectionNames) - 1 Return SetError(0, $aSectionNames[0], $aSectionNames) EndIf If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Return SetError(1, 0, "") If Not $_HINI[$hIniFile][4] Then Return SetError(3, 0, "") If BitAND($iFlags, $INI_ARRAYDATA_NOCOUNT) Then Return SetError(0, $_HINI[$hIniFile][4], StringRegExp($_HINI[$hIniFile][5], "\n([^\r\n]*)", 3)) Return SetError(0, $_HINI[$hIniFile][4], StringRegExp(@LF & $_HINI[$hIniFile][4] & $_HINI[$hIniFile][5], "\n([^\r\n]*)", 3)) EndFunc ;==>_IniReadSectionNamesEx ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniRenameSectionEx ; Description ...: The _IniRenameSectionEx rename the sections in an INI file ; Syntax.........: _IniRenameSectionEx($hIniFile[, $iFlags]) ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; $iFlags - Optional, Flag to indicate the type of action that should be performed (add the flags together for multiple operations): ; |$INI_NOOCCURRENCE (512) - Rename only first section if there are more than one ; |$INI_MERGE (1024) - Join section if more than one in INI\INI file, This Flag will be ignored if the $INI_NOOCCURRENCE is set\used ; |$NULL_REF (NULL) - $hIniFile must be contain INI String\Section\Key\Value\Data ; Return values .: Returns a 0 (check @Extended for number of edit performed) ; @Error - 0 = No error. ; |1 = Invalid IniHandle. ; |3 = SectionName's not found ; Remarks .......: ; Author ........: DXRW4E ; =============================================================================================================================== Func _IniRenameSectionEx(ByRef $hIniFile, $sSectionName, $sNewSectionName, $iFlags = 0) ;;;;If Not $sSectionName Or Not $sNewSectionName Then Return SetError(2, 0, "") ;Invalid Section Name If $iFlags = $NULL_REF Then $hIniFile = StringRegExpReplace($hIniFile, "(?mi)^[\h\f\xb\x0]*\[\K\Q" & StringReplace($sSectionName, "\E", "\e", 0, 1) & "\E(?=\])", StringReplace($sNewSectionName, "\", "\\", 0, 1), (BitAND($iFlags, $INI_NOOCCURRENCE) ? 1 : 0)) Else If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Return SetError(1, 0, "") If StringInStr($sSectionName, "\E", 1) Then $sSectionName = StringReplace($sSectionName, "\E", "\e", 0, 1) $iFlags = BitXOR(BitOR($iFlags, $INI_REMOVE_RENAME), $INI_REMOVE) If BitAND($iFlags, $INI_MERGE_NOOCCURRENCE) = $INI_MERGE And Not __IniReadSectionEx($hIniFile, $sSectionName, $iFlags, $_HINI[$hIniFile][1]) Then Return SetError(3, 0, 0) __IniWriteSectionEx($hIniFile, $sSectionName, $sNewSectionName, $iFlags, $INI_NULL_REF, $_HINI[$hIniFile][1]) EndIf Return SetError(@Error, @Extended, 0) EndFunc ;==>_IniRenameSectionEx ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniWriteEx ; Description ...: Write\Add\Replace\Delete\Change\Edit a KeyName\Value\Data in INI File ; Syntax.........: _IniWriteEx(ByRef $hIniFile, $sSectionName, $sKeyName, $sValue[, $iFlags[, $scKeyName]]) ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; $sSectionName - The name of the section containing the Key\Value, This parameter can be NULL (use the $NULL_REF to set NULL this parameter) ; If $sSectionName is NULL, $hIniFile must be contain Section String\Key\Value\Data ; $sKeyName - The key name in the in the .ini file. ; $sKeyName - The value to write/change. ; $iFlags - Optional, Flag to indicate the type of action that should be performed (add the flags together for multiple operations): ; |$INI_STRIPLEADING (1) - strip leading white space Section, This Flag will be ignored if the $INI_OVERWRITEALL or $INI_APPENDDATA is set\used ; |$INI_STRIPTRAILING (2) - trailing white space Section, This Flag will be ignored if the $INI_OVERWRITEALL or $INI_APPENDDATA is set\used ; |$INI_NOOCCURRENCE (512) - Check only first section if there are more than one ; |$INI_NOCREATE (2048) - Not Create New Section If Section Not Exist ; |$INI_APPENDDATA (4096) - Add KeyName\Value\Data (Append Mod) ; |$INI_REPLACEONLY (8192) - Add KeyName\Value\Data Only if Exist ; |$INI_NOOVERWRITE (32768) - Add KeyName\Value\Data Only if Not Exist ; |$INI_OVERWRITEALL (65536) - Overwrite All data in Section (Replaces all KeyName\Value\Data in the Section) ; |$INI_IGNOREDUPLICATE (131072) - Proceed\Execute (Add\Delete\Replace\Edit ect ect) Once Only (Ignore all other Duplicate\Occurrences of KeyName\Value\Data) ; |$INI_DELETE (262144) - Delete\Remove KeyName\Value\Data ; $scKeyName - Optional, Key-Name separator character, Default is '=', This parameter can not be '"' or @CR or @LF ; Return values .: Returns a 0 (check @Extended for number of edit performed) ; @Error - 0 = No error. ; |1 = Invalid IniHandle. ; |3 = SectionName's not found ; |5 = Invalid KeyName ; Author ........: DXRW4E ; Remarks .......: $INI_MERGE (1024) - (Join section if more than one in INI file) is always set\used by default, to disable it just use the $INI_NOOCCURRENCE ; =============================================================================================================================== Func _IniWriteEx(ByRef $hIniFile, $sSectionName, $sKeyName, $sValue, $iFlags = 0, $scKeyName = "=") ;;If Not $sKeyName Then Return SetError(5, 0, "") If Not $scKeyName Then $scKeyName = "=" If $sSectionName = $NULL_REF Then If BitAND($iFlags, $INI_OVERWRITEALL_APPENDDATA) Then If BitAND($iFlags, $INI_OVERWRITEALL) Then $hIniFile = "" $hIniFile &= $sKeyName & $scKeyName & $sValue & @CRLF Else Local $asKeyValue, $sKNPattern, $iOffSet = StringInStr($hIniFile, @LF, 1) $sKNPattern = '\n[\h\f\xb\x0]*(?i)(?>\Q"' & $sKeyName & '"\E|\Q' & $sKeyName & '\E)[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*[^\n]*' If StringRegExp(StringLeft($hIniFile, $iOffSet), '^(?i)[\h\f\xb\x0]*(?>\Q"' & $sKeyName & '"\E|\Q' & $sKeyName & '\E)[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*[^\n]*') Then If Not BitAND($iFlags, $INI_IGNOREDUPLICATE) Then $hIniFile = StringRegExpReplace($hIniFile, $sKNPattern, "") If BitAND($iFlags, $INI_DELETE) Then $hIniFile = StringTrimLeft($hIniFile, $iOffSet) ElseIf Not BitAND($iFlags, $INI_NOOVERWRITE) Then $hIniFile = $sKeyName & $scKeyName & $sValue & @CRLF & StringTrimLeft($hIniFile, $iOffSet) EndIf ElseIf BitAND($iFlags, $INI_DELETE) Then $hIniFile = StringRegExpReplace($hIniFile, $sKNPattern, "", (BitAND($iFlags, $INI_IGNOREDUPLICATE) ? 1 : 0)) Else $asKeyValue = StringRegExp($hIniFile, $sKNPattern, 1) $iOffSet = @Extended - 1 If Not @Error Then If BitAND($iFlags, $INI_NOOVERWRITE) Then If Not BitAND($iFlags, $INI_IGNOREDUPLICATE) Then $hIniFile = StringLeft($hIniFile, $iOffSet) & StringRegExpReplace(StringTrimLeft($hIniFile, $iOffSet), $sKNPattern, "") Else $hIniFile = StringLeft($hIniFile, $iOffSet + 1 - StringLen($asKeyValue[0])) & $sKeyName & $scKeyName & $sValue & @CR & (BitAND($iFlags, $INI_IGNOREDUPLICATE) ? StringTrimLeft($hIniFile, $iOffSet) : StringRegExpReplace(StringTrimLeft($hIniFile, $iOffSet), $sKNPattern, "")) EndIf ElseIf Not BitAND($iFlags, $INI_REPLACEONLY) Then $hIniFile &= $sKeyName & $scKeyName & $sValue & @CRLF Else Return SetError(0, 0, 0) EndIf EndIf EndIf Return SetError(0, 1, 0) Else If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Return SetError(1, 0, "") ;;;;If Not $sSectionName Then Return SetError(2, 0, "") ;Invalid Section Name If StringInStr($sSectionName, "\E", 1) Then $sSectionName = StringReplace($sSectionName, "\E", "\e", 0, 1) Local $aKeyValue[2][3] = [[1],[$sKeyName,"",$sKeyName & $scKeyName & $sValue]] $iFlags = BitOR(BitXOR($iFlags, BitAND($iFlags, $INI_REMOVE_RENAME)), $INI_MERGE) If $_HINI[$hIniFile][7] <> $sSectionName Or ($_HINI[$hIniFile][8] > 1 And BitAND($iFlags, $INI_MERGE_NOOCCURRENCE) <> BitAND($_HINI[$hIniFile][9], $INI_MERGE_NOOCCURRENCE)) Then __IniReadSectionEx($hIniFile, $sSectionName, $iFlags, $_HINI[$hIniFile][1]) If @Error Then Return SetError(3, 0, "") EndIf __IniWriteSectionEx($hIniFile, $sSectionName, $aKeyValue, $iFlags, $scKeyName, $_HINI[$hIniFile][1]) EndIf Return SetError(@Error, @Extended, 0) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniWriteSectionEx ; Description ...: Add\Replace\Delete\Remove\Rename\Change\Edit a Section\KeyName\Value\Data in INI File. ; Syntax.........: _IniWriteSectionEx() ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; $sSectionName - The name of the section containing the Key\Value\Data ; $aKeyValue - String\Text Data (example 'KeyName=Value 7 @LF & KeyName2=Value2') or an 2DArray is passed as data, the return Array of IniReadSectionEx() can be used immediately. ; If $aKeyValue is String\Text Data and $INI_OVERWRITEALL or $INI_APPENDDATA if Set\Used, $aKeyValue will be writte exactly as in $aKeyValue (without Edit\Formatting) ; $iFlags - Optional, Flag to indicate the type of action that should be performed (add the flags together for multiple operations): ; |$INI_STRIPLEADING (1) - strip leading white space Section, This Flag will be ignored if the $INI_OVERWRITEALL or $INI_APPENDDATA is set\used ; |$INI_STRIPTRAILING (2) - trailing white space Section, This Flag will be ignored if the $INI_OVERWRITEALL or $INI_APPENDDATA is set\used ; |$INI_NOOCCURRENCE (512) - Check only first section if there are more than one ; |$INI_NOCREATE (2048) - Not Create New Section If Section Not Exist ; |$INI_APPENDDATA (4096) - Add KeyName\Value\Data (Append Mod) ; |$INI_REPLACEONLY (8192) - Add KeyName\Value\Data Only if Exist ; |$INI_NOOVERWRITE (32768) - Add KeyName\Value\Data Only if Not Exist ; |$INI_OVERWRITEALL (65536) - Overwrite All data in Section (Replaces all KeyName\Value\Data in the Section) ; |$INI_IGNOREDUPLICATE (131072) - Proceed\Execute (Add\Delete\Replace\Edit ect ect) Once Only (Ignore all other Duplicate\Occurrences of KeyName\Value\Data) ; |$INI_DELETE (262144) - Delete\Remove KeyName\Value\Data ; |$INI_RENAME (524288) - Renames a section ; |$INI_REMOVE (1048576) - Remove\Delete Section ; $scKeyName - Optional, Key-Name separator character, Default is '=', This parameter can not be '"' or @CR or @LF ; Return values .: Returns a 0 (check @Extended for number of edit performed) ; @Error - 0 = No error. ; |1 = Invalid IniHandle. ; |3 = SectionName's not found ; |5 = Invalid KeyName ; Remarks .......: ; Author ........: DXRW4E ; Remarks .......: $INI_MERGE (1024) - (Join section if more than one in INI file) is always set\used by default, to disable it just use the $INI_NOOCCURRENCE ; =============================================================================================================================== Func _IniWriteSectionEx(ByRef $hIniFile, $sSectionName, $aKeyValue, $iFlags = 0, $scKeyName = "=") ;~ If $sSectionName = $NULL_REF Then ;~ If Not $scKeyName Then $scKeyName = "=" ;~ If IsArray($aKeyValue) Then ;~ Local $iCols = UBound($aKeyValue, 2) ;~ If UBound($aKeyValue, 0) <> 2 Or $iCols < 2 Then Return SetError(7, 0, "") ;~ If $iCols = 2 Then ;~ ReDim $aKeyValue[$aKeyValue[0][0] + 1][3] ;~ For $i = 1 To $aKeyValue[0][0] ;~ $aKeyValue[$i][2] = $aKeyValue[$i][0] & $scKeyName & $aKeyValue[$i][1] ;~ Next ;~ EndIf ;~ ElseIf Not BitAND($iFlags, $INI_OVERWRITEALL_APPENDDATA) Then ;~ $aKeyValue = _IniReadSectionEx($aKeyValue, Null, $INI_2DARRAYFIELD, $scKeyName) ;~ If @Error Then Return SetError(7, 0, "") ;~ EndIf ;~ If BitAND($iFlags, $INI_OVERWRITEALL_APPENDDATA) Then ;~ If BitAND($iFlags, $INI_OVERWRITEALL) Then $hIniFile = "" ;~ If IsArray($aKeyValue) Then ;~ For $i = 1 To $aKeyValue[0][0] ;~ $hIniFile &= $aKeyValue[$i][2] & @CRLF ;~ Next ;~ Else ;~ ;; KeyName\Value\Text Data will be writte exactly as in $aKeyValue (without Edit\Formatting ect ect) ;~ $hIniFile &= $aKeyValue & (StringRight($aKeyValue, 1) = @LF ? "" : @CRLF) ;~ EndIf ;~ Return SetError(0, 1, 0) ;~ Else ;~ Local $asKeyValue, $iKeyValue = 0, $sKNPattern, $iOffSet = StringInStr($hIniFile, @LF, 1) ;~ For $i = 1 To $aKeyValue[0][0] ;~ $sKNPattern = '\n[\h\f\xb\x0]*(?i)(?>\Q"' & $aKeyValue[$i][0] & '"\E|\Q' & $aKeyValue[$i][0] & '\E)[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*[^\n]*' ;~ If StringRegExp(StringLeft($hIniFile, $iOffSet), '^(?i)[\h\f\xb\x0]*(?>\Q"' & $aKeyValue[$i][0] & '"\E|\Q' & $aKeyValue[$i][0] & '\E)[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*[^\n]*') Then ;~ If Not BitAND($iFlags, $INI_IGNOREDUPLICATE) Then $hIniFile = StringRegExpReplace($hIniFile, $sKNPattern, "") ;~ If BitAND($iFlags, $INI_DELETE) Then ;~ $hIniFile = StringTrimLeft($hIniFile, $iOffSet) ;~ ElseIf Not BitAND($iFlags, $INI_NOOVERWRITE) Then ;~ $hIniFile = $aKeyValue[$i][2] & @CRLF & StringTrimLeft($hIniFile, $iOffSet) ;~ EndIf ;~ ElseIf BitAND($iFlags, $INI_DELETE) Then ;~ $hIniFile = StringRegExpReplace($hIniFile, $sKNPattern, "", (BitAND($iFlags, $INI_IGNOREDUPLICATE) ? 1 : 0)) ;~ Else ;~ $asKeyValue = StringRegExp($hIniFile, $sKNPattern, 1) ;~ $iOffSet = @Extended - 1 ;~ If Not @Error Then ;~ If BitAND($iFlags, $INI_NOOVERWRITE) Then ;~ If Not BitAND($iFlags, $INI_IGNOREDUPLICATE) Then $hIniFile = StringLeft($hIniFile, $iOffSet) & StringRegExpReplace(StringTrimLeft($hIniFile, $iOffSet), $sKNPattern, "") ;~ Else ;~ $hIniFile = StringLeft($hIniFile, $iOffSet + 1 - StringLen($asKeyValue[0])) & $aKeyValue[$i][2] & @CR & (BitAND($iFlags, $INI_IGNOREDUPLICATE) ? StringTrimLeft($hIniFile, $iOffSet) : StringRegExpReplace(StringTrimLeft($hIniFile, $iOffSet), $sKNPattern, "")) ;~ EndIf ;~ ElseIf Not BitAND($iFlags, $INI_REPLACEONLY) Then ;~ $hIniFile &= $aKeyValue[$i][2] & @CRLF ;~ Else ;~ $iKeyValue -= 1 ;~ EndIf ;~ EndIf ;~ $iKeyValue += 1 ;~ Next ;~ Return SetError(0, $iKeyValue, 0) ;~ EndIf ;~ EndIf If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Return SetError(1, 0, "") ;;;;If Not $sSectionName Then Return SetError(2, 0, "") ;Invalid Section Name If StringInStr($sSectionName, "\E", 1) Then $sSectionName = StringReplace($sSectionName, "\E", "\e", 0, 1) If BitAND($iFlags, $INI_REMOVE) Then __IniWriteSectionEx($hIniFile, $sSectionName, $INI_NULL_REF, $iFlags, $INI_NULL_REF, $_HINI[$hIniFile][1]) ElseIf BitAND($iFlags, $INI_RENAME) Then ;;;; $aKeyValue is New Section Name ;;If Not $aKeyValue Then Return SetError(5, 0, "") If BitAND($iFlags, $INI_MERGE_NOOCCURRENCE) = $INI_MERGE And Not __IniReadSectionEx($hIniFile, $sSectionName, $iFlags, $_HINI[$hIniFile][1]) Then Return SetError(3, 0, 0) __IniWriteSectionEx($hIniFile, $sSectionName, $aKeyValue, $iFlags, $INI_NULL_REF, $_HINI[$hIniFile][1]) Else If Not $scKeyName Then $scKeyName = "=" If IsArray($aKeyValue) Then Local $iCols = UBound($aKeyValue, 2) If UBound($aKeyValue, 0) <> 2 Or $iCols < 2 Then Return SetError(5, 0, "") If $iCols = 2 Then ReDim $aKeyValue[$aKeyValue[0][0] + 1][3] For $i = 1 To $aKeyValue[0][0] $aKeyValue[$i][2] = $aKeyValue[$i][0] & $scKeyName & $aKeyValue[$i][1] Next EndIf ElseIf Not BitAND($iFlags, $INI_OVERWRITEALL_APPENDDATA) Then $aKeyValue = _IniReadSectionEx($aKeyValue, Null, $INI_2DARRAYFIELD, $scKeyName) If @Error Then Return SetError(5, 0, "") EndIf $iFlags = BitOR($iFlags, $INI_MERGE) If $_HINI[$hIniFile][7] <> $sSectionName Or ($_HINI[$hIniFile][8] > 1 And BitAND($iFlags, $INI_MERGE_NOOCCURRENCE) <> BitAND($_HINI[$hIniFile][9], $INI_MERGE_NOOCCURRENCE)) Then __IniReadSectionEx($hIniFile, $sSectionName, $iFlags, $_HINI[$hIniFile][1]) If @Error Then Return SetError(3, 0, "") EndIf __IniWriteSectionEx($hIniFile, $sSectionName, $aKeyValue, $iFlags, $scKeyName, $_HINI[$hIniFile][1]) EndIf Return SetError(@Error, @Extended, 0) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniGetSectionNumberEx ; Description ...: The _IniGetSectionNumberEx Retrieves the number of all sections in an INI file ; Syntax.........: _IniGetSectionNumberEx(Byref $hIniFile) ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; Return values .: Number of Section's ; @Error - 0 = No error. ; |1 = Invalid IniHandle. ; |3 = SectionName's not found ; Remarks .......: ; Author ........: DXRW4E ; =============================================================================================================================== Func _IniGetSectionNumberEx(ByRef $hIniFile) If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Local $aSectionNames = StringRegExp(@LF & $hIniFile, "\n[\h\f\xb\x0]*\[[^\r\n]*\K\]", 3) ;StringRegExp($hIniFile, "(?m)^[\h\f\xb\x0]*\[[^\r\n]*\]", 3) Return SetError(@Error, 0, UBound($aSectionNames)) EndIf Return SetError(($_HINI[$hIniFile][4] ? 0 : 3), 0, $_HINI[$hIniFile][4]) EndFunc ;==>_IniGetSectionNumberEx ; #FUNCTION# =========================================================================================================== ; Name...........: _IniGetFileInformationEx ; Description ...: Returns information about an INI file ; Syntax.........: _IniGetFileInformationEx($hIniFile[, $iFlags]) ; Parameters ....: $hIniFile - Handle of INI file previously opened by _IniOpenFileEx, see _IniOpenFileEx() ; $iFlags - Optional ; |0 - Return INI Handle (Default) ; |1 - Return INI File Array Data (is array of arrays) ; |2 - Return INI File Path ; |3 - Return INI Encoding ; |4 - Return INI Section Number ; Return values .: See Flag parameter ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: ; =============================================================================================================================== Func _IniGetFileInformationEx($hIniFile, $iFlags = 0) If Not $hIniFile Then Return SetError(1, 0, "") If $_HINI[0][1] < 0 Then $_HINI[0][1] = 0 Return SetError(1, 0, "") ElseIf IsString($hIniFile) Then ;;If StringIsDigit($hIniFile) And StringLeft($hIniFile, 1) <> "0" Then ;; $hIniFile = Number($hIniFile) ;;Else For $i = 1 To $_HINI[0][0] If $_HINI[$i][2] = $hIniFile Then ExitLoop Next $hIniFile = $i ;;EndIf EndIf If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Return SetError(1, 0, "") ; Or $hIniFile <> $_HINI[$hIniFile][0] If $iFlags < 1 Or $iFlags > 4 Then Return $hIniFile Return SetError(0, $hIniFile, $_HINI[$hIniFile][$iFlags]) EndFunc ;==>_IniGetFileInformationEx ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniGetFileStringData ; Description ...: The _IniGetFileStringData Retrieves all INI Lines\String\Text Data ; Syntax.........: _IniGetFileStringData(ByRef $hIniFile[, $iFlags]) ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; $iFlags - Optional, Flag to indicate the type of action that should be performed (add the flags together for multiple operations): ; |$INI_STRIPLEADING (1) - strip leading white space Section ; |$INI_STRIPTRAILING (2) - strip trailing white space Section ; Return values .: String\Text Data ; @Error - 0 = No error. ; |1 = Invalid IniHandle. ; Remarks .......: ; Author ........: DXRW4E ; =============================================================================================================================== Func _IniGetFileStringData(ByRef $hIniFile, $iFlags = 0) If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Return SetError(1, 0, "") ;;Local $sData, $iSL = BitAND($iFlags, $INI_STRIPLEADING), $iST = BitAND($iFlags, $INI_STRIPTRAILING) ;;$sData = ($iSL ? "" : ($_HINI[$hIniFile][1])[3]) & ($_HINI[$hIniFile][1])[4] & ($iST ? "" : ($_HINI[$hIniFile][1])[5]) ;;For $i = 6 To ($_HINI[$hIniFile][1])[0] Step 6 ;; $sData &= ($_HINI[$hIniFile][1])[$i] & ($_HINI[$hIniFile][1])[$i + 1] & ($_HINI[$hIniFile][1])[$i + 2] & ($iSL ? "" : ($_HINI[$hIniFile][1])[$i + 3]) & ($_HINI[$hIniFile][1])[$i + 4] & ($iST ? "" : ($_HINI[$hIniFile][1])[$i + 5]) ;;Next Local $sData = __IniGetFileStringData($hIniFile, $iFlags, $_HINI[$hIniFile][1]) Return SetError(0, $_HINI[$hIniFile][3], $sData) EndFunc ;==>_IniGetFileStringData ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniClearCache ; Description ...: Clear INI File Processing Functions Cache ; Syntax.........: _IniClearCache(ByRef $aIniFile) ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; Return values .: None ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: This function is useful to Run after _IniRea*Ex Funcion's, only in the case when in the INI file are duplicated function ; and if the flag $INI_MERGE or $INI_NOOCCURRENCE is not set\used, because in this case the _IniReadEx\_IniReadSectionEx saves ; in cache the Function's\String\Data to be fast during the loop ect ect, so only in cases when you Get\Read Occurrence Function ; and the flag $INI_MERGE or $INI_NOOCCURRENCE is not set\used ; All other function as _IniDeleteEx or _IniWrite*Ex use by Default or Force the use of $INI_MERGE flag ; So in 99.9% of cases you do not Need\Have to run _IniClearCache(), because the INI File Processing Functions Work's only By Reference ; =============================================================================================================================== Func _IniClearCache(ByRef $hIniFile) If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Return SetError(1, 0, "") $_HINI[$hIniFile][6] = "" __IniSaveCache($hIniFile, $_HINI[$hIniFile][6], $INI_NULL_REF, $_HINI[$hIniFile][6], $_HINI[$hIniFile][6], $_HINI[$hIniFile][1]) Return 0 EndFunc ;==>_IniClearCache ; #FUNCTION# ==================================================================================================================== ; Name...........: _IniFileWrite ; Description ...: Write a Ini File ; Syntax.........: _IniFileWriteEx(ByRef $hIniFile[, $iFlags[, $sFilePath[, $iFileEncoding]]]) ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; $iFlags - Optional, Flag to indicate the type of action that should be performed (add the flags together for multiple operations): ; |$INI_STRIPLEADING (1) - strip leading white space Section ; |$INI_STRIPTRAILING (2) - trailing white space Section ; |$INI_NOWRITEREADONLY (16) - Do not Write\Replace\Edit the ReadOnly file (Default Write\Replace\Edit the ReadOnly files) ; $sFilePath - Optional, use alternative FilePath, By Default always is used (Default) PathFile ; $iFileEncoding - Optional, use alternative FileEncoding, By Default always is used (Default) FileEncoding ; Return values .: Returns a 0 ; @Error - 0 = No error. ; |1 = Invalid IniHandle. ; |9 = Invalid FilePath ; |10 = A file may fail to open due to access rights or attributes. ; Remarks .......: ; Author ........: DXRW4E ; =============================================================================================================================== Func _IniFileWriteEx(ByRef $hIniFile, $iFlags = 0, $sFilePath = Default, $iFileEncoding = Default) If $hIniFile < 1 Or $hIniFile > $_HINI[0][0] Then Return SetError(1, 0, "") If $_HINI[$hIniFile][2] = "FileQueue" And Not $sFilePath Then Return SetError(9, 0, "") If $sFilePath = Default Then $sFilePath = $_HINI[$hIniFile][2] If $iFileEncoding = Default Then $iFileEncoding = $_HINI[$hIniFile][3] + 10 ;;Local $hFileOpen, $iSL = BitAND($iFlags, $INI_STRIPLEADING), $iST = BitAND($iFlags, $INI_STRIPTRAILING) ;;$hFileOpen = FileOpen($_HINI[$hIniFile][2], $_HINI[$hIniFile][3] + 10) ;; ;; Check if file opened for writing OK ;;If $hFileOpen = -1 Then ;; Return SetError(10, 0, 0) ;;EndIf ;;FileWrite($hFileOpen, ($iSL ? "" : ($_HINI[$hIniFile][1])[3]) & ($_HINI[$hIniFile][1])[4] & ($iST ? "" : ($_HINI[$hIniFile][1])[5])) ;;For $i = 6 To ($_HINI[$hIniFile][1])[0] Step 6 ;; FileWrite($hFileOpen, ($_HINI[$hIniFile][1])[$i] & ($_HINI[$hIniFile][1])[$i + 1] & ($_HINI[$hIniFile][1])[$i + 2] & ($iSL ? "" : ($_HINI[$hIniFile][1])[$i + 3]) & ($_HINI[$hIniFile][1])[$i + 4] & ($iST ? "" : ($_HINI[$hIniFile][1])[$i + 5])) ;;Next ;;FileClose($hFileOpen) __IniFileWriteEx($hIniFile, $iFlags, $sFilePath, $iFileEncoding, $_HINI[$hIniFile][1]) Return SetError(@Error, @Extended, 0) EndFunc ;==>_IniFileWriteEx ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __IniReadSectionEx ; Description ...: Support Function for _IniReadSectionEx ; Syntax.........: __IniReadSectionEx(ByRef $aIniFile, ByRef $sSectionName, ByRef $iFlags) ; Parameters ....: See _IniReadSectionEx() ; Return values .: See _IniReadSectionEx() ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: This function is used internally by _IniReadSectionEx ; =============================================================================================================================== Func __IniReadSectionEx(ByRef $hIniFile, ByRef $sSectionName, ByRef $iFlags, ByRef $aIniFile) ;;;;If Not $sSectionName Then Return SetError(2, 0, "") ;Invalid Section Name If StringInStr($sSectionName, "\E", 1) Then $sSectionName = StringReplace($sSectionName, "\E", "\e", 0, 1) Local $sSectionData, $aSectionName, $iSectionName = 1 $aSectionName = StringRegExp($_HINI[$hIniFile][5], "\n(?is)\Q" & $sSectionName & "\E\r([^\n]+)", 3) If @Error Then If BitAND($iFlags, $INI_NOCREATE_REMOVE_DELETE) Then Return SetError(3, 0, "") $aIniFile[0] += 6 Redim $aIniFile[$aIniFile[0] + 1] $aIniFile[$aIniFile[0] - 5] = "[" $aIniFile[$aIniFile[0] - 4] = $sSectionName $aIniFile[$aIniFile[0] - 3] = "]" & @CRLF $_HINI[$hIniFile][4] += 1 $_HINI[$hIniFile][5] &= @LF & $sSectionName & @CR & ($aIniFile[0] - 4) $_HINI[$hIniFile][6] = $aIniFile[0] - 1 Else $_HINI[$hIniFile][6] = $aSectionName[0] + 3 $iSectionName = UBound($aSectionName) ;;If BitAND($iFlags, $INI_STRIPLEADTRAILING) = $INI_STRIPLEADTRAILING Then ;; BitOR($INI_STRIPLEADING, $INI_STRIPTRAILING) ;; $sSectionData = $aIniFile[$aSectionName[0] + 3] ;;ElseIf BitAND($iFlags, $INI_STRIPLEADING) Then ;; $sSectionData = $aIniFile[$aSectionName[0] + 3] & $aIniFile[$aSectionName[0] + 4] ;;ElseIf BitAND($iFlags, $INI_STRIPTRAILING) Then ;; $sSectionData = $aIniFile[$aSectionName[0] + 2] & $aIniFile[$aSectionName[0] + 3] ;;Else ;; $sSectionData = $aIniFile[$aSectionName[0] + 2] & $aIniFile[$aSectionName[0] + 3] & $aIniFile[$aSectionName[0] + 4] ;;EndIf If Not BitAND($iFlags, $INI_NOOCCURRENCE) And $iSectionName > 1 Then $sSectionData = $aIniFile[$aSectionName[0] + 3] For $i = 1 To $iSectionName - 1 $sSectionData &= $aIniFile[$aSectionName[$i] + 3] If BitAND($iFlags, $INI_MERGE) Then For $y = $aSectionName[$i] - 1 To $aSectionName[$i] + 4 $aIniFile[$y] = "" Next $_HINI[$hIniFile][5] = StringRegExpReplace($_HINI[$hIniFile][5], '\n(?is)\Q' & $sSectionName & '\E\r' & $aSectionName[$i], "") EndIf Next If BitAND($iFlags, $INI_MERGE) Then $aIniFile[$aSectionName[0] + 3] = $sSectionData EndIf EndIf __IniSaveCache($hIniFile, $sSectionData, $sSectionName, $iFlags, $iSectionName, $aIniFile) Return $iSectionName ;SetError(Not $iSectionName, $iSectionName, $sSectionData) EndFunc ;==>__IniReadSectionEx ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __IniWriteSectionEx ; Description ...: Support Function for _IniWriteSectionEx ; Syntax.........: __IniWriteSectionEx(ByRef $hIniFile, ByRef $sSectionName, ByRef $aKeyValue, ByRef $iFlags, ByRef $scKeyName, ByRef $aIniFile) ; Parameters ....: See _IniWriteSectionEx() ; Return values .: See _IniWriteSectionEx() ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: This function is used internally by _IniWriteSectionEx ; =============================================================================================================================== Func __IniWriteSectionEx(ByRef $hIniFile, ByRef $sSectionName, ByRef $aKeyValue, ByRef $iFlags, ByRef $scKeyName, ByRef $aIniFile) If BitAND($iFlags, $INI_REMOVE) Then Local $iaSectionName, $aSectionName = StringRegExp($_HINI[$hIniFile][5], '\n(?is)\Q' & $sSectionName & '\E\r([^\n]+)', 3) If @Error Then Return SetError(3, 0, 0) $iaSectionName = UBound($aSectionName) - 1 If BitAND($iFlags, $INI_NOOCCURRENCE) Then $iaSectionName = 0 For $i = 0 To $iaSectionName For $y = $aSectionName[$i] - 1 To $aSectionName[$i] + 4 $aIniFile[$y] = "" Next Next $_HINI[$hIniFile][4] -= $iaSectionName + 1 $_HINI[$hIniFile][5] = StringRegExpReplace($_HINI[$hIniFile][5], '\n(?is)\Q' & $sSectionName & '\E\r[^\r\n]+', "", Int($iaSectionName = 0)) Return SetError(0, @Extended, 0) ElseIf BitAND($iFlags, $INI_RENAME) Then Local $iaSectionName, $aSectionName = StringRegExp($_HINI[$hIniFile][5], '\n(?is)\Q' & $sSectionName & '\E\r([^\n]+)', 3) If @Error Then Return SetError(3, 0, 0) $iaSectionName = UBound($aSectionName) - 1 If BitAND($iFlags, $INI_NOOCCURRENCE) Then $iaSectionName = 0 ;; $aKeyValue is New Section Name For $i = 0 To $iaSectionName $aIniFile[$aSectionName[$i]] = $aKeyValue Next $_HINI[$hIniFile][5] = StringRegExpReplace($_HINI[$hIniFile][5], '\n\K(?is)\Q' & $sSectionName & '\E(?=\r)', StringReplace(StringReplace($aKeyValue, "\", "\\", 0, 1), "\E", "\e", 0, 1), Int($iaSectionName = 0)) Return SetError(0, @Extended, 0) Else Local $iSN = $_HINI[$hIniFile][10] If BitAND($iFlags, $INI_OVERWRITEALL_APPENDDATA) Then If BitAND($iFlags, $INI_OVERWRITEALL) Then $aIniFile[$iSN] = "" If BitAND($iFlags, $INI_STRIPLEADING) Then $aIniFile[$iSN - 1] = "" If BitAND($iFlags, $INI_STRIPTRAILING) Then $aIniFile[$iSN + 1] = "" If IsArray($aKeyValue) Then For $i = 1 To $aKeyValue[0][0] $aIniFile[$iSN] &= $aKeyValue[$i][2] & @CRLF Next Else ;; KeyName\Value\Text Data will be writte exactly as in $aKeyValue (without Edit\Formatting ect ect) $aIniFile[$iSN] &= $aKeyValue & (StringRight($aKeyValue, 1) = @LF ? "" : @CRLF) EndIf Return SetError(0, 1, 0) Else Local $asKeyValue, $iKeyValue = 0, $sKNPattern, $iOffSet = StringInStr($aIniFile[$iSN], @LF, 1) For $i = 1 To $aKeyValue[0][0] $sKNPattern = '\n[\h\f\xb\x0]*(?i)(?>\Q"' & $aKeyValue[$i][0] & '"\E|\Q' & $aKeyValue[$i][0] & '\E)[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*[^\n]*' If StringRegExp(StringLeft($aIniFile[$iSN], $iOffSet), '^(?i)[\h\f\xb\x0]*(?>\Q"' & $aKeyValue[$i][0] & '"\E|\Q' & $aKeyValue[$i][0] & '\E)[\h\f\xb\x0]*' & $scKeyName & '[\h\f\xb\x0]*[^\n]*') Then If Not BitAND($iFlags, $INI_IGNOREDUPLICATE) Then $aIniFile[$iSN] = StringRegExpReplace($aIniFile[$iSN], $sKNPattern, "") If BitAND($iFlags, $INI_DELETE) Then $aIniFile[$iSN] = StringTrimLeft($aIniFile[$iSN], $iOffSet) ElseIf Not BitAND($iFlags, $INI_NOOVERWRITE) Then $aIniFile[$iSN] = $aKeyValue[$i][2] & @CRLF & StringTrimLeft($aIniFile[$iSN], $iOffSet) EndIf ElseIf BitAND($iFlags, $INI_DELETE) Then $aIniFile[$iSN] = StringRegExpReplace($aIniFile[$iSN], $sKNPattern, "", (BitAND($iFlags, $INI_IGNOREDUPLICATE) ? 1 : 0)) Else $asKeyValue = StringRegExp($aIniFile[$iSN], $sKNPattern, 1) $iOffSet = @Extended - 1 If Not @Error Then If BitAND($iFlags, $INI_NOOVERWRITE) Then If Not BitAND($iFlags, $INI_IGNOREDUPLICATE) Then $aIniFile[$iSN] = StringLeft($aIniFile[$iSN], $iOffSet) & StringRegExpReplace(StringTrimLeft($aIniFile[$iSN], $iOffSet), $sKNPattern, "") Else $aIniFile[$iSN] = StringLeft($aIniFile[$iSN], $iOffSet + 1 - StringLen($asKeyValue[0])) & $aKeyValue[$i][2] & @CR & (BitAND($iFlags, $INI_IGNOREDUPLICATE) ? StringTrimLeft($aIniFile[$iSN], $iOffSet) : StringRegExpReplace(StringTrimLeft($aIniFile[$iSN], $iOffSet), $sKNPattern, "")) EndIf ElseIf Not BitAND($iFlags, $INI_REPLACEONLY) Then $aIniFile[$iSN] &= $aKeyValue[$i][2] & @CRLF Else $iKeyValue -= 1 EndIf EndIf $iKeyValue += 1 Next Return SetError(0, $iKeyValue, 0) EndIf EndIf EndFunc ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __IniFileWriteEx ; Description ...: Support Function for _IniFileWriteEx ; Syntax.........: __IniFileWriteEx(ByRef $hIniFile, ByRef $iFlags, ByRef $sFilePath, ByRef $iFileEncoding, ByRef $aIniFile) ; Parameters ....: See _IniFileWriteEx() ; Return values .: See _IniFileWriteEx() ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: This function is used internally by _IniFileWriteEx ; =============================================================================================================================== Func __IniFileWriteEx(ByRef $hIniFile, ByRef $iFlags, ByRef $sFilePath, ByRef $iFileEncoding, ByRef $aIniFile) Local $hFileOpen, $iSL = BitAND($iFlags, $INI_STRIPLEADING), $iST = BitAND($iFlags, $INI_STRIPTRAILING), $iReadOnly = 0 $hFileOpen = FileOpen($sFilePath, $iFileEncoding) ; Check if file opened for writing OK If $hFileOpen = -1 Then If Not BitAND($iFlags, $INI_NOWRITEREADONLY) And StringInStr(FileGetAttrib($sFilePath), "R") Then FileSetAttrib($sFilePath, "-R") $iReadOnly = 1 $hFileOpen = FileOpen($sFilePath, $iFileEncoding) If $hFileOpen = -1 Then Return SetError(10, 0, 0) Else Return SetError(10, 0, 0) EndIf EndIf FileWrite($hFileOpen, ($iSL ? "" : $aIniFile[3]) & $aIniFile[4] & ($iST ? "" : $aIniFile[5])) For $i = 6 To $aIniFile[0] Step 6 FileWrite($hFileOpen, $aIniFile[$i] & $aIniFile[$i + 1] & $aIniFile[$i + 2] & ($iSL ? "" : $aIniFile[$i + 3]) & $aIniFile[$i + 4] & ($iST ? "" : $aIniFile[$i + 5])) Next FileClose($hFileOpen) If $iReadOnly Then FileSetAttrib($sFilePath, "+R") Return 0 EndFunc ;==>__IniFileWriteEx ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __IniGetFileStringData ; Description ...: Support Function for _IniGetFileStringData ; Syntax.........: __IniGetFileStringData(ByRef $hIniFile, ByRef $iFlags, ByRef $aIniFile) ; Parameters ....: See _IniGetFileStringData() ; Return values .: See _IniGetFileStringData() ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: This function is used internally by _IniGetFileStringData ; =============================================================================================================================== Func __IniGetFileStringData(ByRef $hIniFile, ByRef $iFlags, ByRef $aIniFile) Local $sData, $iSL = BitAND($iFlags, $INI_STRIPLEADING), $iST = BitAND($iFlags, $INI_STRIPTRAILING) Local $sData = ($iSL ? "" : $aIniFile[3]) & $aIniFile[4] & ($iST ? "" : $aIniFile[5]) For $i = 6 To $aIniFile[0] Step 6 $sData &= $aIniFile[$i] & $aIniFile[$i + 1] & $aIniFile[$i + 2] & ($iSL ? "" : $aIniFile[$i + 3]) & $aIniFile[$i + 4] & ($iST ? "" : $aIniFile[$i + 5]) Next Return $sData EndFunc ;==>__IniGetFileStringData ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __IniSaveCache ; Description ...: Save in Cache last Read Section ; Syntax.........: __IniSaveCache(ByRef $hIniFile, ByRef $sSectionData, ByRef $sSectionName, ByRef $iFlags, ByRef $iSectionName, ByRef $aIniFile) ; Parameters ....: $hIniFile - Handle to the INI file to query "see _IniOpenFileEx()" ; $sSectionData - Section Strings text/data ; $sSectionName - Section Name ; $iFlags - Section Flags ; $iSectionName - Number of SectionName in INI File ; $aIniFile - Array of INI File ; Return values .: None ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: This function is Internal Only ; =============================================================================================================================== Func __IniSaveCache(ByRef $hIniFile, ByRef $sSectionData, ByRef $sSectionName, ByRef $iFlags, ByRef $iSectionName, ByRef $aIniFile) $_HINI[$hIniFile][7] = $sSectionName $_HINI[$hIniFile][8] = (BitAND($iFlags, $INI_MERGE_NOOCCURRENCE) = $INI_MERGE) ? 1 : $iSectionName $_HINI[$hIniFile][9] = $iFlags If $iSectionName > 1 And Not BitAND($iFlags, $INI_MERGE_NOOCCURRENCE) Then $aIniFile[1] = $sSectionData $_HINI[$hIniFile][10] = 1 Else $aIniFile[1] = "" $_HINI[$hIniFile][10] = $_HINI[$hIniFile][6] EndIf Return 0 EndFunc ;==>__IniSaveCache ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __GetSeparatorCharacter ; Description ...: Get Separator Character (non present character) ; Syntax.........: __GetSeparatorCharacter(ByRef $sData) ; Parameters ....: $sData - INI String\Text Data ; Return values .: None ; Author ........: DXRW4E ; Modified.......: ; Remarks .......: For Internal Use Only ; =============================================================================================================================== Func __GetSeparatorCharacter(ByRef $sData) If Not StringInStr($sData, ChrW(8232), 1) Then Return ChrW(8232) If Not StringInStr($sData, ChrW(8233), 1) Then Return ChrW(8233) For $i = 1 To 31 If $i > 8 And $i < 14 Then ContinueLoop If Not StringInStr($sData, Chr($i), 1) Then Return Chr($i) Next $sData = StringRegExpReplace($sData, '\r\n?', @LF) Return @CR EndFunc ;==>__GetSeparatorCharacter example #include <IniEx.au3> #include <Array.au3> Local $sData = @CRLF, $aData, $iData, $iTimerDiff, $hIniFile FileDelete(@DesktopDir & "\Test.ini") For $i = 1 To 10 $sData &= "[SectionName_" & $i & "]" & @CRLF For $y = 1 to 100000 $sData &= "KeyName" & $y & " = Value" & $y & @CRLF Next Next FileWrite(@DesktopDir & "\Test.ini", $sData) ;25 MB - 1.000.000 Line, Key-Value $sData = "" $iTimerDiff = TimerInit() ;;_IniOpenFileEx() $hIniFile = _IniOpenFileEx(@DesktopDir & "\Test.ini") If @Error Then ConsoleWrite("Error - " & @Error & @LF) Exit EndIf $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("_IniOpenFileEx TimerDiff - " & $iTimerDiff & @LF) $iTimerDiff = TimerInit() ;;_IniGetSectionNumberEx() $iData = _IniGetSectionNumberEx($hIniFile) If @Error Then ConsoleWrite("Error - " & @Error & @LF) Exit EndIf $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("IniGetSectionNumberEx TimerDiff - " & $iTimerDiff & @LF) ConsoleWrite("SectionNumber - " & $iData & @LF & @LF) $iTimerDiff = TimerInit() ;;_IniRenameSectionEx() _IniRenameSectionEx($hIniFile, "SectionName_10", "SectionName_111") If @Error Then ConsoleWrite("Error - " & @Error & @LF) Exit EndIf $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("IniRenameSectionEx TimerDiff - " & $iTimerDiff & @LF & @LF) $iTimerDiff = TimerInit() ;;_IniReadSectionNamesEx() $aData = _IniReadSectionNamesEx($hIniFile) If @Error Then ConsoleWrite("Error - " & @Error & @LF) Exit EndIf $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("IniReadSectionNamesEx TimerDiff - " & $iTimerDiff & @LF & @LF) _ArrayDisplay($aData) $iTimerDiff = TimerInit() ;;_IniReadSectionEx() $sData = _IniReadSectionEx($hIniFile, "SectionName_8") $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("IniReadSectionEx TimerDiff - " & $iTimerDiff & @LF & @LF) ;;ConsoleWrite($sData & @LF & @LF) ;;MsgBox(0, "SectionName_8", $sData) $iTimerDiff = TimerInit() ;;_IniReadSectionEx() $aData = _IniReadSectionEx($hIniFile, "SectionName_8", $INI_2DARRAYFIELD) ;$INI_NOOCCURRENCE + $INI_MERGE + $INI_2DARRAYFIELD $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("IniReadSectionEx TimerDiff - " & $iTimerDiff & @LF & @LF) _ArrayDisplay($aData, "IniReadSectionEx") $iTimerDiff = TimerInit() ;;_IniReadEx() $sData = _IniReadEx($hIniFile, "SectionName_8", "KeyName99980") $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("IniReadEx TimerDiff - " & $iTimerDiff& @LF) ConsoleWrite($sData & @LF & @LF) $iTimerDiff = TimerInit() ;;_IniReadEx() $aData = _IniReadEx($hIniFile, "SectionName_8", "KeyName99988", "Default Return", $INI_ARRAYDATA) ;$INI_NOOCCURRENCE + $INI_MERGE + $INI_ARRAYDATA $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("IniReadEx TimerDiff - " & $iTimerDiff & @LF) ConsoleWrite($aData[1] & @LF & @LF) _ArrayDisplay($aData, "IniReadEx") $iTimerDiff = TimerInit() ;;_IniDeleteEx() _IniDeleteEx($hIniFile, "SectionName_8", "KeyName99988") ;$INI_IGNOREDUPLICATE + $INI_NOOCCURRENCE + $INI_REMOVE $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("IniDeleteEx TimerDiff - " & $iTimerDiff & @LF & @LF) $iTimerDiff = TimerInit() ;;_IniWriteSectionEx() _IniWriteSectionEx($hIniFile, "SectionName_8", "KeyNameX = ValueX") ; $INI_NOOCCURRENCE + $INI_IGNOREDUPLICATE + $INI_MERGE + $INI_REMOVE + $INI_OVERWRITEALL + $INI_APPENDDATA $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("IniWriteSectionEx TimerDiff - " & $iTimerDiff & @LF & @LF) ConsoleWrite(_IniReadEx($hIniFile, "SectionName_8", "KeyNameX") & @LF) $iTimerDiff = TimerInit() For $i = 1 To 5 _IniWriteSectionEx($hIniFile, "SectionName_8", "KeyNameX" & $i & " = ValueX" & $i) Next For $i = 6 To 10 _IniWriteEx($hIniFile, "SectionName_8", "KeyNameX" & $i, "ValueX" & $i) Next $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("IniWrite*Ex TimerDiff - " & $iTimerDiff & @LF) $iTimerDiff = TimerInit() ;;_IniReadEx() For $i = 1 To 10 ConsoleWrite(_IniReadEx($hIniFile, "SectionName_8", "KeyNameX" & $i) & @LF) Next $iTimerDiff = TimerDiff($iTimerDiff) ConsoleWrite("IniReadEx TimerDiff - " & $iTimerDiff & @LF) _IniCloseFileEx($hIniFile) Exit ;~ >Running:(3.3.11.3):C:\Program Files (x86)\AutoIt3\Beta\autoit3.exe "C:\Users\DXRW4E\Desktop\New AutoIt v3 Script.au3" ;~ --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop ;~ _IniOpenFileEx TimerDiff - 2656.48548057389 ;~ IniGetSectionNumberEx TimerDiff - 0.0343594296492653 ;~ SectionNumber - 10 ;~ ;~ IniRenameSectionEx TimerDiff - 0.204971769976651 ;~ ;~ IniReadSectionNamesEx TimerDiff - 0.0584505240010489 ;~ ;~ IniReadSectionEx TimerDiff - 6.80316707055452 ;~ ;~ IniReadSectionEx TimerDiff - 1831.04639075913 ;~ ;~ IniReadEx TimerDiff - 24.1380917325683 ;~ Value99980 ;~ ;~ IniReadEx TimerDiff - 111.67841469541 ;~ Value99988 ;~ ;~ IniDeleteEx TimerDiff - 43.9488700091941 ;~ ;~ IniWriteSectionEx TimerDiff - 28.2560891228314 ;~ ;~ ValueX ;~ IniWrite*Ex TimerDiff - 261.353224415258 ;~ ValueX1 ;~ ValueX2 ;~ ValueX3 ;~ ValueX4 ;~ ValueX5 ;~ ValueX6 ;~ ValueX7 ;~ ValueX8 ;~ ValueX9 ;~ ValueX10 ;~ IniReadEx TimerDiff - 261.622965684803 ;~ +>00:07:21 AutoIt3.exe ended.rc:0 ;~ >Exit code: 0 Time: 5.914 ; $INI_OPEN_FILEQUEUE (268435456) - Open INI file from Memory\Variable, $sFilePath must contain String Text Data of INI file $hIniFile = _IniOpenFileEx(@DesktopDir & "\Test.ini") ;ect ect ect ;or $hIniFile = _IniOpenFileEx($sData, $INI_OPEN_FILEQUEUE) ;ect ect ect ;Or direct mode, without load ini or using handles ; $sSectionName - The name of the section containing the Key\Value, This parameter can be NULL (use the $NULL_REF to set NULL this parameter) ; If $sSectionName is NULL, $hIniFile must be contain Section String\Key\Value\Data ;; _IniDeleteEx($hIniFile, $sSectionName, $sKeyName) _IniDeleteEx($sData, $NULL_REF, $sKeyName) ;$NULL_REF = NULL ;; _IniReadEx($hIniFile, $sSectionName, $sKeyName) _IniDeleteEx($sData, $NULL_REF, $sKeyName) ;$NULL_REF = NULL ;; _IniReadSectionEx($hIniFile, $sSectionName, $sKeyName) _IniReadSectionEx($sData, $NULL_REF, $sKeyName) ;$NULL_REF = NULL ;; _IniWriteEx($hIniFile, $sSectionName, $sKeyName, $sValue) _IniWriteEx($sData, $NULL_REF, $sKeyName, $sValue) ;$NULL_REF = NULL ;;ect ect ect So for all other functions IniEx.au31 point -
When processing files, especially large ones, you will always lose battle if riding AutoIt. Not to mention RAM suffocation. So, what if I leave the whole process on a level that is few steps below me and just collect the cream? Script includes functions and small example: Opt("MustDeclareVars", 1) Global $sFile = FileOpenDialog("Choose file", "", "All files (*)") If @error Then Exit Global $hTimer, $iTimer, $sData ;------------------------------------------------------------------------ ; CRC32: $hTimer = TimerInit() $sData = _CRC32ForFile($sFile) $iTimer = TimerDiff($hTimer) ConsoleWrite("! CRC32 took " & $iTimer & " ms" & @CRLF) ConsoleWrite("Result: " & $sData & @CRLF & @CRLF) ;------------------------------------------------------------------------ ; MD4: $hTimer = TimerInit() $sData = _MD4ForFile($sFile) $iTimer = TimerDiff($hTimer) ConsoleWrite("! MD4 took " & $iTimer & " ms" & @CRLF) ConsoleWrite("Result: " & $sData & @CRLF & @CRLF) ;------------------------------------------------------------------------ ; MD5: $hTimer = TimerInit() $sData = _MD5ForFile($sFile) $iTimer = TimerDiff($hTimer) ConsoleWrite("! MD5 took " & $iTimer & " ms" & @CRLF) ConsoleWrite("Result: " & $sData & @CRLF & @CRLF) ;------------------------------------------------------------------------ ; SHA1: $hTimer = TimerInit() $sData = _SHA1ForFile($sFile) $iTimer = TimerDiff($hTimer) ConsoleWrite("! SHA1 took " & $iTimer & " ms" & @CRLF) ConsoleWrite("Result: " & $sData & @CRLF & @CRLF) ;------------------------------------------------------------------------ ; Functions... ; #FUNCTION# ;=============================================================================== ; ; Name...........: _CRC32ForFile ; Description ...: Calculates CRC32 value for the specific file. ; Syntax.........: _CRC32ForFile ($sFile) ; Parameters ....: $sFile - Full path to the file to process. ; Return values .: Success - Returns CRC32 value in form of hex string ; - Sets @error to 0 ; Failure - Returns empty string and sets @error: ; |1 - CreateFile function or call to it failed. ; |2 - CreateFileMapping function or call to it failed. ; |3 - MapViewOfFile function or call to it failed. ; |4 - RtlComputeCrc32 function or call to it failed. ; Author ........: trancexx ; ;========================================================================================== Func _CRC32ForFile($sFile) Local $a_hCall = DllCall("kernel32.dll", "hwnd", "CreateFileW", _ "wstr", $sFile, _ "dword", 0x80000000, _ ; GENERIC_READ "dword", 3, _ ; FILE_SHARE_READ|FILE_SHARE_WRITE "ptr", 0, _ "dword", 3, _ ; OPEN_EXISTING "dword", 0, _ ; SECURITY_ANONYMOUS "ptr", 0) If @error Or $a_hCall[0] = -1 Then Return SetError(1, 0, "") EndIf Local $hFile = $a_hCall[0] $a_hCall = DllCall("kernel32.dll", "ptr", "CreateFileMappingW", _ "hwnd", $hFile, _ "dword", 0, _ ; default security descriptor "dword", 2, _ ; PAGE_READONLY "dword", 0, _ "dword", 0, _ "ptr", 0) If @error Or Not $a_hCall[0] Then DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFile) Return SetError(2, 0, "") EndIf DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFile) Local $hFileMappingObject = $a_hCall[0] $a_hCall = DllCall("kernel32.dll", "ptr", "MapViewOfFile", _ "hwnd", $hFileMappingObject, _ "dword", 4, _ ; FILE_MAP_READ "dword", 0, _ "dword", 0, _ "dword", 0) If @error Or Not $a_hCall[0] Then DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Return SetError(3, 0, "") EndIf Local $pFile = $a_hCall[0] Local $iBufferSize = FileGetSize($sFile) Local $a_iCall = DllCall("ntdll.dll", "dword", "RtlComputeCrc32", _ "dword", 0, _ "ptr", $pFile, _ "int", $iBufferSize) If @error Or Not $a_iCall[0] Then DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile) DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Return SetError(4, 0, "") EndIf DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile) DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Local $iCRC32 = $a_iCall[0] Return SetError(0, 0, Hex($iCRC32)) EndFunc ;==>_CRC32ForFile ; #FUNCTION# ;=============================================================================== ; ; Name...........: _MD4ForFile ; Description ...: Calculates MD4 value for the specific file. ; Syntax.........: _MD4ForFile ($sFile) ; Parameters ....: $sFile - Full path to the file to process. ; Return values .: Success - Returns MD4 value in form of hex string ; - Sets @error to 0 ; Failure - Returns empty string and sets @error: ; |1 - CreateFile function or call to it failed. ; |2 - CreateFileMapping function or call to it failed. ; |3 - MapViewOfFile function or call to it failed. ; |4 - MD4Init function or call to it failed. ; |5 - MD4Update function or call to it failed. ; |6 - MD4Final function or call to it failed. ; Author ........: trancexx ; ;========================================================================================== Func _MD4ForFile($sFile) Local $a_hCall = DllCall("kernel32.dll", "hwnd", "CreateFileW", _ "wstr", $sFile, _ "dword", 0x80000000, _ ; GENERIC_READ "dword", 3, _ ; FILE_SHARE_READ|FILE_SHARE_WRITE "ptr", 0, _ "dword", 3, _ ; OPEN_EXISTING "dword", 0, _ ; SECURITY_ANONYMOUS "ptr", 0) If @error Or $a_hCall[0] = -1 Then Return SetError(1, 0, "") EndIf Local $hFile = $a_hCall[0] $a_hCall = DllCall("kernel32.dll", "ptr", "CreateFileMappingW", _ "hwnd", $hFile, _ "dword", 0, _ ; default security descriptor "dword", 2, _ ; PAGE_READONLY "dword", 0, _ "dword", 0, _ "ptr", 0) If @error Or Not $a_hCall[0] Then DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFile) Return SetError(2, 0, "") EndIf DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFile) Local $hFileMappingObject = $a_hCall[0] $a_hCall = DllCall("kernel32.dll", "ptr", "MapViewOfFile", _ "hwnd", $hFileMappingObject, _ "dword", 4, _ ; FILE_MAP_READ "dword", 0, _ "dword", 0, _ "dword", 0) If @error Or Not $a_hCall[0] Then DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Return SetError(3, 0, "") EndIf Local $pFile = $a_hCall[0] Local $iBufferSize = FileGetSize($sFile) Local $tMD4_CTX = DllStructCreate("dword i[2];" & _ "dword buf[4];" & _ "ubyte in[64];" & _ "ubyte digest[16]") DllCall("advapi32.dll", "none", "MD4Init", "ptr", DllStructGetPtr($tMD4_CTX)) If @error Then DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile) DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Return SetError(4, 0, "") EndIf DllCall("advapi32.dll", "none", "MD4Update", _ "ptr", DllStructGetPtr($tMD4_CTX), _ "ptr", $pFile, _ "dword", $iBufferSize) If @error Then DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile) DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Return SetError(5, 0, "") EndIf DllCall("advapi32.dll", "none", "MD4Final", "ptr", DllStructGetPtr($tMD4_CTX)) If @error Then DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile) DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Return SetError(6, 0, "") EndIf DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile) DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Local $sMD4 = Hex(DllStructGetData($tMD4_CTX, "digest")) Return SetError(0, 0, $sMD4) EndFunc ;==>_MD4ForFile ; #FUNCTION# ;=============================================================================== ; ; Name...........: _MD5ForFile ; Description ...: Calculates MD5 value for the specific file. ; Syntax.........: _MD5ForFile ($sFile) ; Parameters ....: $sFile - Full path to the file to process. ; Return values .: Success - Returns MD5 value in form of hex string ; - Sets @error to 0 ; Failure - Returns empty string and sets @error: ; |1 - CreateFile function or call to it failed. ; |2 - CreateFileMapping function or call to it failed. ; |3 - MapViewOfFile function or call to it failed. ; |4 - MD5Init function or call to it failed. ; |5 - MD5Update function or call to it failed. ; |6 - MD5Final function or call to it failed. ; Author ........: trancexx ; ;========================================================================================== Func _MD5ForFile($sFile) Local $a_hCall = DllCall("kernel32.dll", "hwnd", "CreateFileW", _ "wstr", $sFile, _ "dword", 0x80000000, _ ; GENERIC_READ "dword", 3, _ ; FILE_SHARE_READ|FILE_SHARE_WRITE "ptr", 0, _ "dword", 3, _ ; OPEN_EXISTING "dword", 0, _ ; SECURITY_ANONYMOUS "ptr", 0) If @error Or $a_hCall[0] = -1 Then Return SetError(1, 0, "") EndIf Local $hFile = $a_hCall[0] $a_hCall = DllCall("kernel32.dll", "ptr", "CreateFileMappingW", _ "hwnd", $hFile, _ "dword", 0, _ ; default security descriptor "dword", 2, _ ; PAGE_READONLY "dword", 0, _ "dword", 0, _ "ptr", 0) If @error Or Not $a_hCall[0] Then DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFile) Return SetError(2, 0, "") EndIf DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFile) Local $hFileMappingObject = $a_hCall[0] $a_hCall = DllCall("kernel32.dll", "ptr", "MapViewOfFile", _ "hwnd", $hFileMappingObject, _ "dword", 4, _ ; FILE_MAP_READ "dword", 0, _ "dword", 0, _ "dword", 0) If @error Or Not $a_hCall[0] Then DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Return SetError(3, 0, "") EndIf Local $pFile = $a_hCall[0] Local $iBufferSize = FileGetSize($sFile) Local $tMD5_CTX = DllStructCreate("dword i[2];" & _ "dword buf[4];" & _ "ubyte in[64];" & _ "ubyte digest[16]") DllCall("advapi32.dll", "none", "MD5Init", "ptr", DllStructGetPtr($tMD5_CTX)) If @error Then DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile) DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Return SetError(4, 0, "") EndIf DllCall("advapi32.dll", "none", "MD5Update", _ "ptr", DllStructGetPtr($tMD5_CTX), _ "ptr", $pFile, _ "dword", $iBufferSize) If @error Then DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile) DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Return SetError(5, 0, "") EndIf DllCall("advapi32.dll", "none", "MD5Final", "ptr", DllStructGetPtr($tMD5_CTX)) If @error Then DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile) DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Return SetError(6, 0, "") EndIf DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile) DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Local $sMD5 = Hex(DllStructGetData($tMD5_CTX, "digest")) Return SetError(0, 0, $sMD5) EndFunc ;==>_MD5ForFile ; #FUNCTION# ;=============================================================================== ; ; Name...........: _SHA1ForFile ; Description ...: Calculates SHA1 value for the specific file. ; Syntax.........: _SHA1ForFile ($sFile) ; Parameters ....: $sFile - Full path to the file to process. ; Return values .: Success - Returns SHA1 value in form of hex string ; - Sets @error to 0 ; Failure - Returns empty string and sets @error: ; |1 - CreateFile function or call to it failed. ; |2 - CreateFileMapping function or call to it failed. ; |3 - MapViewOfFile function or call to it failed. ; |4 - CryptAcquireContext function or call to it failed. ; |5 - CryptCreateHash function or call to it failed. ; |6 - CryptHashData function or call to it failed. ; |7 - CryptGetHashParam function or call to it failed. ; Author ........: trancexx ; ;========================================================================================== Func _SHA1ForFile($sFile) Local $a_hCall = DllCall("kernel32.dll", "hwnd", "CreateFileW", _ "wstr", $sFile, _ "dword", 0x80000000, _ ; GENERIC_READ "dword", 3, _ ; FILE_SHARE_READ|FILE_SHARE_WRITE "ptr", 0, _ "dword", 3, _ ; OPEN_EXISTING "dword", 0, _ ; SECURITY_ANONYMOUS "ptr", 0) If @error Or $a_hCall[0] = -1 Then Return SetError(1, 0, "") EndIf Local $hFile = $a_hCall[0] $a_hCall = DllCall("kernel32.dll", "ptr", "CreateFileMappingW", _ "hwnd", $hFile, _ "dword", 0, _ ; default security descriptor "dword", 2, _ ; PAGE_READONLY "dword", 0, _ "dword", 0, _ "ptr", 0) If @error Or Not $a_hCall[0] Then DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFile) Return SetError(2, 0, "") EndIf DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFile) Local $hFileMappingObject = $a_hCall[0] $a_hCall = DllCall("kernel32.dll", "ptr", "MapViewOfFile", _ "hwnd", $hFileMappingObject, _ "dword", 4, _ ; FILE_MAP_READ "dword", 0, _ "dword", 0, _ "dword", 0) If @error Or Not $a_hCall[0] Then DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Return SetError(3, 0, "") EndIf Local $pFile = $a_hCall[0] Local $iBufferSize = FileGetSize($sFile) Local $a_iCall = DllCall("advapi32.dll", "int", "CryptAcquireContext", _ "ptr*", 0, _ "ptr", 0, _ "ptr", 0, _ "dword", 1, _ ; PROV_RSA_FULL "dword", 0xF0000000) ; CRYPT_VERIFYCONTEXT If @error Or Not $a_iCall[0] Then DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile) DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) Return SetError(4, 0, "") EndIf Local $hContext = $a_iCall[1] $a_iCall = DllCall("advapi32.dll", "int", "CryptCreateHash", _ "ptr", $hContext, _ "dword", 0x00008004, _ ; CALG_SHA1 "ptr", 0, _ ; nonkeyed "dword", 0, _ "ptr*", 0) If @error Or Not $a_iCall[0] Then DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile) DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) DllCall("advapi32.dll", "int", "CryptReleaseContext", "ptr", $hContext, "dword", 0) Return SetError(5, 0, "") EndIf Local $hHashSHA1 = $a_iCall[5] $a_iCall = DllCall("advapi32.dll", "int", "CryptHashData", _ "ptr", $hHashSHA1, _ "ptr", $pFile, _ "dword", $iBufferSize, _ "dword", 0) If @error Or Not $a_iCall[0] Then DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile) DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) DllCall("advapi32.dll", "int", "CryptDestroyHash", "ptr", $hHashSHA1) DllCall("advapi32.dll", "int", "CryptReleaseContext", "ptr", $hContext, "dword", 0) Return SetError(6, 0, "") EndIf Local $tOutSHA1 = DllStructCreate("byte[20]") $a_iCall = DllCall("advapi32.dll", "int", "CryptGetHashParam", _ "ptr", $hHashSHA1, _ "dword", 2, _ ; HP_HASHVAL "ptr", DllStructGetPtr($tOutSHA1), _ "dword*", 20, _ "dword", 0) If @error Or Not $a_iCall[0] Then DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile) DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) DllCall("advapi32.dll", "int", "CryptDestroyHash", "ptr", $hHashSHA1) DllCall("advapi32.dll", "int", "CryptReleaseContext", "ptr", $hContext, "dword", 0) Return SetError(7, 0, "") EndIf DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile) DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject) DllCall("advapi32.dll", "int", "CryptDestroyHash", "ptr", $hHashSHA1) Local $sSHA1 = Hex(DllStructGetData($tOutSHA1, 1)) DllCall("advapi32.dll", "int", "CryptReleaseContext", "ptr", $hContext, "dword", 0) Return SetError(0, 0, $sSHA1) EndFunc ;==>_SHA1ForFile Results are in form of hex strings, but that is easily changed to fit your needs. First time is the hardest - you will see what I mean if you run it (file mapping related). Try it on something big.1 point
-
Post what you have now and I will have a test with it. You should be in the normal members now so the 5 posts limit is lifted. Jos1 point
-
Perhaps it would be an idea to ask the Windows locale for default split character ? Some parts of the world (at least mine) uses ; to split since we have comma as decimal. So we have Bob;Doe;1234,49 John;Doe;9948,12 Jane;Doe;1999,00 Welcomed UDF though !1 point
-
I would like to have timestamps on autoIT traces
philkryder reacted to gruntydatsun for a topic
This file implements TraceAdd() function. C:Program FilesAutoIt3SciTELUAAutoItTools.lua Good luck1 point -
AutoIT Script Request
lorenkinzel reacted to JohnOne for a topic
I have that code. Sorry I don't have time to post it.1 point -
Ok let's go Here an invisible gui is needed - sort of 'message only' - to get the WM_INPUT message #include <GUIConstantsEx.au3> #Include <WindowsConstants.au3> HotKeySet('{ESC}', '_Exit') Global Const $RID_INPUT = 0x10000003 Global Const $RIDEV_INPUTSINK = 0x00000100 Global Const $RI_MOUSE_BUTTON_4_DOWN = 0x0040 Global Const $RI_MOUSE_BUTTON_5_DOWN = 0x0100 Global Const $RIM_TYPEMOUSE = 0 If Not IsDeclared('WM_INPUT') Then Global Const $WM_INPUT = 0x00FF Global Const $tagRAWINPUTDEVICE = 'ushort usUsagePage;ushort usUsage;dword dwFlags;hwnd hwndTarget;' Global Const $tagRAWINPUTHEADER = 'dword dwType;dword dwSize;hwnd hDevice;uint_ptr wParam;' Global Const $tagRAWMOUSE = 'ushort usFlags;ushort usAlignment;ushort usButtonFlags;' & _ 'ushort usButtonData;ulong ulRawButtons;long lLastX;long lLastY;ulong ulExtraInformation' Global Const $tagRAWINPUT_MOUSE = $tagRAWINPUTHEADER & $tagRAWMOUSE ;====================================== $hGUI = GUICreate("test") ; fake GUIRegisterMsg($WM_INPUT, 'WM_INPUT') $tRID_M = DllStructCreate($tagRAWINPUTDEVICE) $pRID_M = DllStructGetPtr($tRID_M) $iRID_M = DllStructGetSize($tRID_M) $tRIH = DllStructCreate($tagRAWINPUTHEADER) $pRIH = DllStructGetPtr($tRIH) $iRIH = DllStructGetSize($tRIH) DllStructSetData($tRID_M, 'usUsagePage', 0x01) DllStructSetData($tRID_M, 'usUsage', 0x02) DllStructSetData($tRID_M, 'dwFlags', $RIDEV_INPUTSINK) DllStructSetData($tRID_M, 'hwndTarget', $hGUI) _RegisterRawInputDevices($pRID_M, 1, $iRID_M) While 1 Sleep(10) WEnd ;========================================= Func WM_INPUT($hwnd, $iMsg, $iwParam, $ilParam) Local $tRI_M, $pRI_M, $iRI_M, $iSize $tRI_M = DllStructCreate($tagRAWINPUT_MOUSE) $pRI_M = DllStructGetPtr($tRI_M) $iRI_M = DllStructGetSize($tRI_M) _GetRawInputData($ilParam, $RID_INPUT, $pRI_M, $iRI_M, $iRIH) Local $Flags = DllStructGetData($tRI_M, 'usButtonFlags') Select Case BitAND($Flags, $RI_MOUSE_BUTTON_4_DOWN) MsgBox(4096, "", "XButton 1") Case BitAND($Flags, $RI_MOUSE_BUTTON_5_DOWN) MsgBox(4096, "", "XButton 2") EndSelect Return $GUI_RUNDEFMSG EndFunc ;=================================== Func _Exit() Exit EndFunc Func _GetRawInputData($hRawInput, $iCommand, $pData, ByRef $iSize, $iSizeHeader, $hDll = 'user32.dll') Local $aRet $aRet = DllCall($hDll, 'uint', 'GetRawInputData', 'hwnd', $hRawInput, 'uint', $iCommand, 'ptr', $pData, 'uint*', $iSize, 'uint', $iSizeHeader) If @error Or $aRet[0] = 4294967295 Then Return SetError(1, 0, $aRet[0]) $iSize = $aRet[4] Return $aRet[0] EndFunc Func _RegisterRawInputDevices($pRawInputDevices, $iNumDevices, $iSize, $hDll = 'user32.dll') Local $aRet $aRet = DllCall($hDll, 'int', 'RegisterRawInputDevices', 'ptr', $pRawInputDevices, 'uint', $iNumDevices, 'uint', $iSize) If @error Or $aRet[0] = 0 Then SetError(1, 0, 0) Return $aRet[0] EndFunc I was too lazy to translate, but the funcs used exist in WinApiEx.au3 and the examples provided in the UDF are very explicit (_WinAPI_GetRawInputData , _WinAPI_RegisterRawInputDevices) Searching in Google "mouse hook vs raw input" will give you more infos about these 2 ways1 point
-
Posting a picture to facebook
Servant reacted to obscurant1st for a topic
Its finished, thanks for the support guys!1 point -
Facebook Login Pretty Simple #NoTrayIcon #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <GUIConstants.au3> #include <GDIPlus.au3> #include <String.au3> #Include <WinAPI.au3> #include <array.au3> #include <Misc.au3> #include <IE.au3> FBLogin() Func FBLogin() Global $Enter = False Local $msg, $GUI_FBN, $GUI_FBP $GUI = GUICreate("F a c e b o o k | L o g i n", 385, 110) $GUI_Label1 = GUICtrlCreateLabel("Email Address:", 10, 28) $GUI_FBN = GUICtrlCreateInput("", 100, 25, 200, 20) $GUI_Label2 = GUICtrlCreateLabel("Login Password:", 10, 53) $GUI_FBP = GUICtrlCreateInput("", 100, 50, 200, 20, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL)) $GUI_Create = GUICtrlCreateButton("Login", 100, 75, 200, 20) $BACKGROUNDX = GuiCtrlCreatePic("Facebook.gif", 310 ,20 ,64, 64) GUICtrlSetState($BACKGROUNDX, $GUI_DISABLE) GUISetState() HotKeySet("{Enter}", "EnterPressed") While 1 $msg = GUIGetMsg() If WinActive("F a c e b o o k | L o g i n") Then HotKeySet("{Enter}", "EnterPressed") Else HotKeySet("{Enter}") EndIf If $msg = -3 Then Exit If $msg = $GUI_Create Or $Enter = True Then Global $Enter = False If GUICtrlRead($GUI_FBN) = "" Then MsgBox(48, "F a c e b o o k | E r r o r", "Fields are Blank, Please Fill in the Fields...") Else $1 = GUICtrlRead($GUI_FBN) $2 = GUICtrlRead($GUI_FBP) $timeout = 5000 _IEErrorHandlerRegister() _IELoadWaitTimeout($timeout) $oIE = _IECreate("http://www.facebook.com/login.php") $oHWND = _IEPropertyGet($oIE, "hwnd") WinSetState($oHWND, "", @SW_MAXIMIZE) $oForm = _IEFormGetObjByName($oIE, "login_form") $oQuery = _IEFormElementGetObjByName($oForm, "email") $o_Query = _IEFormElementGetObjByName($oForm, "pass") $oSubmit = _IEFormElementGetObjByName($oForm, "login") _IEFormElementSetValue($oQuery, $1) _IEFormElementSetValue($o_Query, $2) _IEAction($oSubmit, "click") ExitLoop EndIf EndIf WEnd EndFunc ;FBLgin() Any Feedback? Gedzy Download: MediaFire1 point