Leaderboard
Popular Content
Showing content with the highest reputation on 05/19/2019 in all areas
-
For $i = 0 To UBound($Checkbox) - 1 If GUICtrlRead($Checkbox[$i]) = $GUI_CHECKED Then ConsoleWrite(GUICtrlRead($Checkbox[$i], 1) & @CRLF) Next3 points
-
May I suggest to read this page of the help file to "associate a gui button with a key"2 points
-
Loga - A logging Library
user4157124 reacted to Danyfirex for a topic
Hello guys. It's been awhile since I shared something. So today I want to share my last project. What's Loga? Loga is a simple logging library to keep track of code with an integrated console. Features. Common log levels. Integrated console. Multiple instances. Custom color and font for each instance log level. Define output format with macros. Conditional and occasional Logging. Easy to use. Basic Usage: #include "..\Loga.au3" ;This are some of the default settings: ;Default log level $LOGA_LEVEL_TRACE ;output format: {Symbol}{LogIndex} {LevelName} {LongDateTime} {Message} ;Log to File is enabled. ;Log file name format: YYYYMMDDHHMM-Loga-InstanceIndex.log ;Custom Console is disabled by default. ;By default log to STDOUT. _LogaTrace("I'm Trace") _LogaDebug("I'm Debug") _LogaInfo("I'm Info") _LogaWarn("I'm Warn") _LogaError("I'm Error") _LogaFatal("I'm Fatal") More examples here. Check Loga on GitHub. Loga Latest Release v1.0.2. Saludos1 point -
How to get Checkbox Captions names?
youtuber reacted to FrancescoDiMuro for a topic
@youtuber Something like this: $arrCheckBoxes[0][0] = GUICtrlCreateCheckbox(...) $arrCheckboxes[0][1] = ".JPG" ; And so on for as many checkboxes you want to set By the way, @mikell gives you the easiest solution, as long as the text you display is the one you want to retrieve; else, you need to do something like above1 point -
Trying to guess the possible issues and using the provided infos, may I suggest this pattern '<span class="price">\s*([^<]+)'1 point
-
No, I would prefer you simply post an script that shows the issue so we can help you.1 point
-
UIAutomation to detect controls that have repeated AutomationID and properties
RadicalKoncepts reacted to junkew for a topic
Uiawrappers also have index, instance and indexrelative. So if simplespy highlights the object you just have to tweak description to identify object. Make sure to use latest version from uiawrappers.1 point -
How to get Checkbox Captions names?
youtuber reacted to FrancescoDiMuro for a topic
@youtuber Create a two-dimension array; in the first column, you store the ControlID of the checkbox, and in the second column you store its label, so when you use GUICtrlRead() in a For...Next loop, you just need to use For $i = 0 To UBound($arrCheckBoxes) - 1 Step 1 If GUICtrlRead($arrCheckBoxes[$i][0]) = $GUI_CHECKED Then ConsoleWrite($arrCheckBoxes[$i][1] & @CRLF) Next to retrieve the information about the label of the checked checkbox(es)1 point -
I dont make scripts for people who dont properly sanitize their input, its gross1 point
-
I routinely need to log information for my scripts. In the past, I've usually just created functions in each script to write to a log file. I also use ConsoleWrite in conjunction with SciTE a lot when I'm trying to debug scripts. After using some logging libraries for other languages (namely NLog (C#) and Java (log4j)) I decided to write a logging UDF for AutoIt. I decided to base it loosely upon the log4j and NLog libaries. I say loosely because this one is not nearly as feature rich as either one of those, but I think it still provides a nice logging interface. What can it do? Output types: Console, File, or Both. Additionally, you can configure the logger to output differently based on whether the script is compiled or not. This way you can output to the console (SciTE) while you're writing a script, and output to a log file when you've compile the script. Log levels: While I don't think it's really necessary to have this many log levels, these are the levels in ascending order of severity: Trace Debug Info Warn Error Fatal Log Filtering: The log can be enabled and disabled. There are also minimum and maximum log levels that can be configured to only show a range of log levels (i.e. a minimum level of warn would not log messages for trace, debug, or info). These filter levels can be overridden when logging a message if the need be. Error Stream: Logging can be configured to write to the stderr (i.e. ConsoleWriteError). When enabled, any log messages at the error level and above will be written to the error stream. Message Format Macros: The logging message format can be customized to your liking using the following macros: ${date} = Long date (i.e. MM/DD/YYYY HH:MM:SS) ${host} = Hostname of local machine ${level} = The current log level ${message} = The log message ${newline} = Insert a newline ${shortdate} = Short date (i.e. MM/DD/YYYY) Available Functions: Configuration Functions _log4a_SetCompiledOutput - Sets the logging output type for the compiled version of the script (Default: $LOG4A_OUTPUT_FILE) _log4a_SetEnable - Enables or disables logging messages (Default: Disabled) _log4a_SetErrorStream - Enables or disables logging of the standard error stream (Default: Enabled) _log4a_SetFormat - Configures the format of logging messages (Default: "${date} ${level} ${message}") _log4a_SetLogFile - Sets the path of the log file (Default: "<ScriptFullPath>.log") _log4a_SetMaxLevel - Configures the maximum log level to process messages (Default: $LOG4A_LEVEL_FATAL) _log4a_SetMinLevel - Configures the minimum log level to process messages (Default: $LOG4A_LEVEL_TRACE) _log4a_SetOutput - Sets the logging output type for the non-compiled version of the script (Default: $LOG4A_OUTPUT_CONSOLE) Logging Functions _log4a_Debug - Logs a message at the debug level _log4a_Error - Logs a message at the error level _log4a_Fatal - Logs a message at the fatal level _log4a_Info - Logs a message at the info level _log4a_Message - Logs a message to the configured outputs _log4a_Trace - Logs a message at the trace level _log4a_Warn - Logs a message at the warn level See the source file for full documentation of available functions. A quick example script: #include "log4a.au3" ; Enable logging and don't write to stderr _log4a_SetEnable() _log4a_SetErrorStream(False) log_messages() ; Write to stderr, set min level to warn, customize message format _log4a_SetErrorStream() _log4a_SetMinLevel($LOG4A_LEVEL_INFO) If @compiled Then _log4a_SetMinLevel($LOG4A_LEVEL_WARN) ; Change the min level if the script is compiled _log4a_SetFormat("${shortdate} | ${host} | ${level} | ${message}") log_messages() ; Disable logging (except for those that override) _log4a_SetEnable(False) log_messages() Func log_messages() _log4a_Trace("A TRACE message", True) ; overrides filters _log4a_Debug("A DEBUG message") _log4a_Info("A INFO message") _log4a_Warn("A WARN message") _log4a_Error("A ERROR message", True) ; overrides filters _log4a_Fatal("A FATAL message") EndFunc Without further adieu, the UDF: log4a.au31 point
-
Here is my ErrorLog.au3 UDF which I use every day. ErrorLog.au3 UDF is for log program activities and errors, to different output with possibility to switch output function instantly. UDF: #include-once #AutoIt3Wrapper_Run_AU3Check=Y #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #Tidy_Parameters=/sort_funcs /reel ; #AutoIt3Wrapper_Run_Debug_Mode=Y Global $__g_bUDF_ERRORLOG_FORCE_DEBUG = False Global $__g_sUDF_ERRORLOG_PREFIX = '--> ' Global $__g_sUDF_ERRORLOG_PREFIX_SUCCESS = '+ ' Global $__g_sUDF_ERRORLOG_PREFIX_EXTENDED = '- ' Global $__g_sUDF_ERRORLOG_PREFIX_ERROR = '! ' #Region ErrorLog.au3 - UDF Header ; #INDEX# ======================================================================================================================= ; Title .........: ErrorLog.au3 UDF - A logging Library ; AutoIt Version : 3.3.10.2++ ; Language ......: English ; Description ...: ErrorLog.au3 UDF is for log program activities and errors, to different output with possibility to switch output function instantly ; Author(s) .....: mLipok ; Modified ......: ; URL ...........: https://www.autoitscript.com/forum/topic/195882-errorlogau3-a-logging-library/ ; =============================================================================================================================== #cs UDF ChangeLog 2018/10/11 v1.0 * Added: UDF #INDEX# - mLipok * Added: UDF ChangeLog - mLipok * Added: Function: _Log_Errors_Reset() - mLipok * Renamed: Function: _Log_Errors() >> _Log_OnError() - mLipok * Changed: Function: better documentation in function headers - mLipok * Added: ErrorLog__Example.au3 - _Log_Example_1() , _Log_Example_2(), _Log_Example_3() - mLipok 2018/10/12 v1.1 * Added: Function: __Log_Wrapper() - a wrapper which put report to the output function - mLipok * Changed: Function: _Log_SetOutputFunction(Default) - return only function in any other case fires @error - mLipok * Refactored: Function: _Log() - mLipok * Refactored: Function: _Log_OnError() - mLipok * Added: GLOBAL: $__g_bUDF_ERRORLOG_FORCE_DEBUG - mLipok * Added: GLOBAL: $__g_sUDF_ERRORLOG_PREFIX_EXTENDED - mLipok * Added: GLOBAL: $__g_sUDF_ERRORLOG_PREFIX_SUCCESS - mLipok * Changed: GLOBAL: $__g_sUDF_ERRORLOG_ERROR_PREFIX >> $__g_sUDF_ERRORLOG_PREFIX_ERROR - mLipok * Added: Function: _Log_OnSuccess() - Log report to the output function but only if @error was not fired - mLipok * Added: Function: _Log_OnExtended() - Log report to the output function but only if @extended is set and @error was not fired - mLipok * Added: Function: _Log_Debug() - Log report to the output function but only if _Log_SetDebugMode(True) was used - mLipok * Added: Function: _Log_SetDebugMode() - Set the _Log_Debug() ON/OFF - mLipok * Changed: Function: much better documentation in function headers - mLipok * Added: UDF: #Region <> #EndRegion - mLipok * Added: UDF: #Tidy_Parameters=/sort_funcs /reel * Added: ErrorLog__Example.au3 - $__g_bUDF_ERRORLOG_FORCE_DEBUG - _Log_SetDebugMode() - mLipok * Added: ErrorLog__Example.au3 - _Log_Debug() - mLipok @LAST CHANGE LOG #ce UDF ChangeLog #EndRegion ErrorLog.au3 - UDF Header #Region ErrorLog.au3 - Functions ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Log ; Description ...: Log report to the output function ; Syntax ........: _Log($sText[, $iError = @error[, $iExtended = @extended]]) ; Parameters ....: $sText - a string value. Textual data which should be reported to the output function ; $iError - [optional] an integer value. Default is @error. Used to store @error ; $iExtended - [optional] an integer value. Default is @extended. Used to store @extended ; Return values .: None - and set @error and @extended to stored values ; Author ........: mLipok ; Modified ......: ; Remarks .......: This function will not send log reports to output if _Log_SetOutputFunction() is not properly set ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Log($sText = '', $iError = @error, $iExtended = @extended) __Log_Wrapper( _ (($iError Or $iExtended) ? ($__g_sUDF_ERRORLOG_PREFIX_ERROR & '[ ' & $iError & ' / ' & $iExtended & ' ] : ') : ($__g_sUDF_ERRORLOG_PREFIX)) _ & $sText _ ) Return SetError($iError, $iExtended) EndFunc ;==>_Log ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Log_Change ; Description ...: Log report to the output function but only if @error or @extended occurs OR if reported data has changed ; Syntax ........: _Log_Change([$sText = ''[, $iError = @error[, $iExtended = @extended]]]) ; Parameters ....: $sText - a string value. Textual data which should be reported to the output function ; $iError - [optional] an integer value. Default is @error. ; $iExtended - [optional] an integer value. Default is @extended. ; Return values .: None - and set @error and @extended to stored values ; Author ........: mLipok ; Modified ......: ; Remarks .......: This function will not send log reports to output if there is no change and no message, or if _Log_SetOutputFunction() is not properly set ; Related .......: _Log ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Log_Change($sText = '', $iError = @error, $iExtended = @extended) Local Static $sText_static = '' Local Static $iError_static = 0 Local Static $iExtended_static = 0 If $sText <> '' Or $iError Or $iExtended And _ ($sText_static <> $sText Or $iError_static <> $iError Or $iExtended_static <> $iExtended) _ Then _Log($sText, $iError, $iExtended) $sText_static = $sText $iError_static = $iError $iExtended_static = $iExtended EndIf Return SetError($iError, $iExtended) EndFunc ;==>_Log_Change ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Log_Debug ; Description ...: Log report to the output function but only if _Log_SetDebugMode(True) was used ; Syntax ........: _Log_Debug($sText[, $iError = @error[, $iExtended = @extended]]) ; Parameters ....: $sText - a string value. Textual data which should be reported to the output function ; $iError - [optional] an integer value. Default is @error. Used to store @error ; $iExtended - [optional] an integer value. Default is @extended. Used to store @extended ; Return values .: None - and set @error and @extended to stored values ; Author ........: mLipok ; Modified ......: ; Remarks .......: This function will not send log reports to output if _Log_SetOutputFunction() is not properly set ; Related .......: _Log ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Log_Debug($sText, $iScriptLineNumber = @ScriptLineNumber, $iError = @error, $iExtended = @extended) If $__g_bUDF_ERRORLOG_FORCE_DEBUG == True Then __Log_Wrapper('@@ Debug(' & $iScriptLineNumber & ') : [ ' & $iError & ' / ' & $iExtended & ' ] : ' & $sText) Return SetError($iError, $iExtended) EndFunc ;==>_Log_Debug ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Log_Errors_Reset ; Description ...: Resetting @error and @extended to 0 ; Syntax ........: _Log_Errors_Reset() ; Parameters ....: None ; Return values .: None - and set @error and @extended to 0 ; Author ........: mLipok ; Modified ......: ; Remarks .......: this is only wrapper for SetError(0, 0) ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Log_Errors_Reset() Return SetError(0, 0) EndFunc ;==>_Log_Errors_Reset ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Log_Errors_ReStore ; Description ...: Restore previously stored @error and @extended ; Syntax ........: _Log_Errors_ReStore() ; Parameters ....: None ; Return values .: None - and set @error and @extended to stored values ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: _Log_Errors_Store ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Log_Errors_ReStore() _Log_Errors_Store(Default, Default) Return SetError(@error, @extended) EndFunc ;==>_Log_Errors_ReStore ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Log_Errors_Store ; Description ...: Store @error and @extended ; Syntax ........: _Log_Errors_Store([$iError = @error[, $iExtended = @extended]]) ; Parameters ....: $iError - [optional] an integer value. Default is @error. ; $iExtended - [optional] an integer value. Default is @extended. ; Return values .: None - and set @error and @extended to stored values ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: _Log_Errors_ReStore ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Log_Errors_Store($iError = @error, $iExtended = @extended) Local Static $iError_static = 0, $iExtended_static = 0 If $iError = Default And $iExtended = Default Then $iError = $iError_static $iExtended = $iExtended_static $iError_static = 0 $iExtended_static = 0 Return SetError($iError, $iExtended) EndIf $iError_static = $iError $iExtended_static = $iExtended Return SetError($iError, $iExtended) EndFunc ;==>_Log_Errors_Store ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Log_OnError ; Description ...: Log report to the output function but only if @error occurs ; Syntax ........: _Log_OnError($sText[, $iError = @error[, $iExtended = @extended]]) ; Parameters ....: $sText - a string value. Textual data which should be reported to the output function ; $iError - [optional] an integer value. Default is @error. Used to store @error ; $iExtended - [optional] an integer value. Default is @extended. Used to store @extended ; Return values .: None - and set @error and @extended to stored values ; Author ........: mLipok ; Modified ......: ; Remarks .......: This function will not send log reports to output if _Log_SetOutputFunction() is not properly set ; Related .......: _Log ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Log_OnError($sText, $iError = @error, $iExtended = @extended) If $iError Then __Log_Wrapper($__g_sUDF_ERRORLOG_PREFIX_ERROR & '@error=' & $iError & ' @extended=' & $iExtended & ' :: ' & $sText) Return SetError($iError, $iExtended) EndFunc ;==>_Log_OnError ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Log_OnExtended ; Description ...: Log report to the output function but only if @extended is set and @error was not fired - mLipok ; Syntax ........: _Log_OnExtended($sText[, $iError = @error[, $iExtended = @extended]]) ; Parameters ....: $sText - a string value. Textual data which should be reported to the output function ; $iError - [optional] an integer value. Default is @error. Used to store @error ; $iExtended - [optional] an integer value. Default is @extended. Used to store @extended ; Return values .: None - and set @error and @extended to stored values ; Author ........: mLipok ; Modified ......: ; Remarks .......: This function will not send log reports to output if _Log_SetOutputFunction() is not properly set ; Related .......: _Log ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Log_OnExtended($sText, $iError = @error, $iExtended = @extended) If $iExtended And $iError = 0 Then __Log_Wrapper($__g_sUDF_ERRORLOG_PREFIX_EXTENDED & '[ ' & $iError & ' / ' & $iExtended & ' ] : ' & $sText) Return SetError($iError, $iExtended) EndFunc ;==>_Log_OnExtended ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Log_OnSuccess ; Description ...: Log report to the output function but only if @error was not fired ; Syntax ........: _Log_OnSuccess($sText[, $iError = @error[, $iExtended = @extended]]) ; Parameters ....: $sText - a string value. Textual data which should be reported to the output function ; $iError - [optional] an integer value. Default is @error. Used to store @error ; $iExtended - [optional] an integer value. Default is @extended. Used to store @extended ; Return values .: None - and set @error and @extended to stored values ; Author ........: mLipok ; Modified ......: ; Remarks .......: This function will not send log reports to output if _Log_SetOutputFunction() is not properly set ; Related .......: _Log ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Log_OnSuccess($sText, $iError = @error, $iExtended = @extended) If $iError = 0 Then __Log_Wrapper($__g_sUDF_ERRORLOG_PREFIX_SUCCESS & '[ ' & $iError & ' / ' & $iExtended & ' ] : ' & $sText) Return SetError($iError, $iExtended) EndFunc ;==>_Log_OnSuccess ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Log_SetDebugMode ; Description ...: Set the _Log_Debug() ON/OFF ; Syntax ........: _Log_SetOutputFunction($bForceDebug) ; Parameters ....: $bForceDebug - a boolean value. True=ON, False=OFF for _Log_Debug() ; Return values .: none or set @error to 1 ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: _Log_Debug ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Log_SetDebugMode($bForceDebug) If Not IsBool($bForceDebug) Then Return SetError(1) $__g_bUDF_ERRORLOG_FORCE_DEBUG = $bForceDebug EndFunc ;==>_Log_SetDebugMode ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Log_SetOutputFunction ; Description ...: Set the function to which Log reports should be passed ; Syntax ........: _Log_SetOutputFunction([$fnFunction = Default]) ; Parameters ....: $fnFunction - [optional] a floating point value. Default is Default. ; Return values .: $fnFunction_static - saved output function, in any other case fires @error ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Log_SetOutputFunction($fnFunction = Default) Local Static $fnFunction_static = Null If $fnFunction = Default And IsFunc($fnFunction_static) Then Return $fnFunction_static If Not IsFunc($fnFunction) Then Return SetError(1) $fnFunction_static = $fnFunction Return $fnFunction_static EndFunc ;==>_Log_SetOutputFunction #EndRegion ErrorLog.au3 - Functions #Region ErrorLog.au3 - Internal Functions ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: __Log_Wrapper ; Description ...: a wrapper which put report to the output function ; Syntax ........: __Log_Wrapper($sText) ; Parameters ....: $sText - a string value. Textual data which should be reported to the output function ; Return values .: None or set @error = 1 in case _Log_SetOutputFunction() was not used or used not properly ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: _Log, _Log_OnError, _Log_OnExtended, _Log_OnSuccess, _Log_Change ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func __Log_Wrapper($sText) Local $fnFunction = _Log_SetOutputFunction() If @error Then Return SetError(1) $fnFunction($sText) EndFunc ;==>__Log_Wrapper #EndRegion ErrorLog.au3 - Internal Functions EXAMPLE: #include <WinAPIProc.au3> #include-once #AutoIt3Wrapper_Run_AU3Check=Y #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ; #AutoIt3Wrapper_Run_Debug_Mode=Y ; #Tidy_Parameters=/sort_funcs /reel #include <Debug.au3> #include "ErrorLog.au3" If Not @Compiled Then $__g_bUDF_ERRORLOG_FORCE_DEBUG = True ; Pre set function to where log report is passed _Log_SetOutputFunction(ConsoleWrite) _Log_Debug("EXAMPLE 1: START" & @CRLF, @ScriptLineNumber) _Log_Example_1() ; check again for @error If @error Then MsgBox($MB_ICONERROR, 'Example 1: Error Occured', _ 'File Reading Problem.' & @CRLF & _ '@error = ' & @error & @CRLF & _ '@extended = ' & @extended _ ) _Log_Debug("EXAMPLE 2: START" & @CRLF, @ScriptLineNumber) _Log_Example_2() _Log_Debug("EXAMPLE 3: START", @ScriptLineNumber) _Log_Example_3() _Log_SetOutputFunction(_ConsoleWrite_Wrapper) _Log_Debug("EXAMPLES: END", @ScriptLineNumber) Func _Log_Example_1() ; sending description to log output _Log('Example 1: We are trying to read file.' & @CR) ; fire @error FileRead('FILE PATH WHICH NOT EXIST') ; report @error but do not change it - store it and back it again _Log_OnError('Example 1: File Reading Problem.' & @CR) Return SetError(@error, @extended) EndFunc ;==>_Log_Example_1 Func _Log_Example_2() ; set function to where log reports will be passed _Log_SetOutputFunction(_ConsoleWrite_Wrapper) ; sending description to log output _Log('Example 2: We are trying to read file.') For $iAttempt_idx = 1 To 15 _log('Example 2: $iAttempt_idx = ' & $iAttempt_idx) ; fire @error If $iAttempt_idx < 14 Then FileRead('FILE PATH WHICH NOT EXIST') ; next line will log only in step #12 and #13 - as only to step #13 , errors ocurrs If $iAttempt_idx > 11 Then _Log_OnError('Example 2: File Reading error' & @CR) ; fake @error to show what _Log_Change() will do when @error is changing If $iAttempt_idx = 5 Then SetError(2) ; fake @exteneded to show what _Log_Change() will do when @exteneded is changing If $iAttempt_idx = 10 Then SetError(@error, 2) ; string change If $iAttempt_idx > 13 Then _Log_Change('Some other log data') ; report to log output but only first unique occurance _Log_Change('Example 2: File Reading Problem.' & @CR) _Log_Errors_Reset() ; if you do not reset then @error and @extended could be followed to next loop. Next EndFunc ;==>_Log_Example_2 Func _Log_Example_3() ; set function to where log reports will be passed _Log_SetOutputFunction(_ConsoleWrite_Wrapper) ; sending description to log output _Log('Example 3: We are trying to read file.') For $iAttempt_idx = 1 To 15 ; If $iAttempt_idx = 9 change output function - from this moment log reports will be passed to _DebugOut() instead _ConsoleWrite_Wrapper() If $iAttempt_idx = 9 Then _DebugSetup("Example 3: ErrorLog.au3 - output") _Log_SetOutputFunction(_DebugOut) EndIf _log('Example 3: $iAttempt_idx = ' & $iAttempt_idx) ; fire @error If $iAttempt_idx < 14 Then FileRead('FILE PATH WHICH NOT EXIST') ; next line will log only in step #12 and #13 - as only to step #13 , errors ocurrs If $iAttempt_idx > 11 Then _Log_OnError('Example 3: File Reading error') ; fake @error to show what _Log_Change() will do when @error is changing If $iAttempt_idx = 5 Then SetError(2) ; fake @exteneded to show what _Log_Change() will do when @exteneded is changing If $iAttempt_idx = 10 Then SetError(@error, 2) ; string change If $iAttempt_idx > 13 Then _Log_Change('Example 3: Some other log data') ; report to log output but only first unique occurance _Log_Change('Example 3: File Reading Problem.' & @CR) _Log_Errors_Reset() ; if you do not reset then @error and @extended could be followed to next loop. Next EndFunc ;==>_Log_Example_3 Func _ConsoleWrite_Wrapper($sData) ConsoleWrite($sData & @CRLF) EndFunc ;==>_ConsoleWrite_Wrapper REMARKS: Documentation in function headers is currently complete1 point
-
Simple Logging UDF - Log.au3 based on log4j / NLog
user4157124 reacted to jvanegmond for a topic
This is a logging library for AutoIt. This library allows you to log messages with different log levels. The log levels are $LOG_TRACE, $LOG_DEBUG, $LOG_INFO, $LOG_WARN, $LOG_ERROR, $LOG_FATAL. These levels are described on the Log4j Wikipedia page. Each message is logged to the console (ConsoleWriteError for $LOG_ERROR and $LOG_FATAL and ConsoleWrite for all other levels) and to a file. You can choose the filename and a directory (see LogFile), but if you don't the log file will be in the same directory as the program and called @ScriptName & ".log". You can also choose to disable logs below a certain log level (see LogLevel). You can also completely customize the format of the log text (see LogFormat). log.au3 Here's an example on how to use this library: #include <log.au3> LogTrace("This is an example trace message") LogDebug("This is an example debug message") LogInfo("This is an example info message") LogWarn("This is an example warning message") LogError("This is an example error message") LogFatal("This is an example fatal message") The output looks like this: [2014-08-13 21:06:50.582 TRACE] This is an example trace message [2014-08-13 21:06:50.582 DEBUG] This is an example debug message [2014-08-13 21:06:50.582 INFO ] This is an example info message [2014-08-13 21:06:50.582 WARN ] This is an example warning message [2014-08-13 21:06:50.591 ERROR] This is an example error message [2014-08-13 21:06:50.591 FATAL] This is an example fatal message Additionally, these functions are available for your convenience: LogFile($sFileName) #include <log.au3> LogFile("C:\example.log") LogInfo("This is an example info message") and the output will appear on the C: drive in a file called example.log. LogLevel($iMinLevel) #include <log.au3> LogLevel($LOG_INFO) LogTrace("This is an example trace message and it will not appear in the logs") LogInfo("This is an example info message and it will appear in the logs") LogFatal("This is an example fatal message and it will appear in the logs") The LogTrace call will have no effect. Only the LogInfo and LogFatal message will appear in the log. LogStart() #include <log.au3> LogStart() LogInfo("This is an example info message") Output: [2014-08-13 21:14:42.886 INFO ] C:\Users\jvanegmond\Desktop\example.au3 started. [2014-08-13 21:14:42.888 INFO ] This is an example info message LogFormat($fFormatFunc) #include <log.au3> LogFormat(MyLogFormat) LogTrace("This is an example trace message") LogDebug("This is an example debug message") LogInfo("This is an example info message") LogWarn("This is an example warning message") LogError("This is an example error message") LogFatal("This is an example fatal message") Func MyLogFormat($sLevel, $sMessage) Return @HOUR & ":" & @MIN & ":" & @SEC & " " & StringStripWS($sLevel, 8) & " " & $sMessage EndFunc Shows the output: 11:39:52 TRACE This is an example trace message 11:39:52 DEBUG This is an example debug message 11:39:52 INFO This is an example info message 11:39:52 WARN This is an example warning message 11:39:52 ERROR This is an example error message 11:39:52 FATAL This is an example fatal message Please let me know what I can remove from this library so that it can fit your use-case better. Edit: Changes: v1.2 Support for log format v1.1 Create directory structure for log file v1.0 Initial release1 point -
How to rename iexplore.exe to iexploreOrg.exe ?
Exit reacted to JLogan3o13 for a topic
Neither the 32bit or the 64bit version can be renamed for obvious common sense reasons. Think about the door opened if you could change the name of system files with a simple AutoIt script. You need to think of a better way to accomplish what you're after, as this is not something we are going to support.0 points