Jump to content

user4157124

Active Members
  • Posts

    57
  • Joined

Reputation Activity

  1. Like
    user4157124 got a reaction from gogloc in Download a file reading first a local txt file which contains the full url   
    _Download(@ScriptDir & '\mp3.txt', 'files_links', @DesktopDir & '\mp3-songs\')  
  2. Like
    user4157124 reacted to PeterVerbeek in Peace Equalizer shows power of AutoIt   
    In this post I take the opportunity to show the awesome capabilities of AutoIt and its libraries. My open source project Peace is a long running AutoIt based app located on SourceForge. It provides users with a system-wide equalizer and effects machine. It's an interface using the power of Equalizer APO, an audio processing object software. Peace has been download over 2,600,000 times by various kind of users. Amongst others it gives them possibilities like these:
    Hearing impaired - Amplify the gain of frequencies which are impaired. Home Theatre - Create Equalizer presets for watching movies and listening to music. Music lovers & audiophiles - Create presets for listening to music on their high quality speakers and headphones. Gamers - Enhance frequencies to get an edge over other gamers. Headphones - Improve the sound quality of cheap headphones and get the max out of expensive ones. Bass lovers - Boost low frequencies for extra bass. Voice - Make a microphone sound better and improve the voice, for instance for YouTube usage. Low audio - Boost low audio of an input source to a comfortable level. This list covers the main needs of the Peace user. Many people have contacted me over the years asking for new features and telling me how they use Peace for their (sometimes specific) needs.  I was able to use AutoIt and its libraries for all of their needs. So what are the main features of Peace?
    Equalize your computer audio by using up to 31 sliders. Support of equalizing 9 speakers : left/right, center, subwoofer, left/right rear, left/right side. Per slider a filter can be chosen such as peak, low/high pass, shelving. The graph windows shows your equalization so you see exactly what you're doing. Apply an effect such as crossfeed simple/Jan Meier/Chu Moy, stereo balance, bass/treble, upmix/downmix, channel routing. Save presets (called configurations) and activate by mouse click, hotkey, desktop shortcut or Peace system tray. Select a target device to equalize, microphone as input can also be equalized. Automate: you can let Peace automatically activate presets on a switch to another device and another process. Peace is available in these languages: English, Czech, Deutsch, Français, Italiano, Nederlands, Pусский, Українська So who am I? I'm a Dutch programmer who happens the stumble upon AutoIt 5 years ago and created a small Equalizer interface app of less than 400 program lines with it. Nowadays Peace has grown to more than 18,000 lines as many features were added. Although Peace is open source, the program code isn't of the best possible quality. The reason being that I didn't expect it to become so popular. It caught me by supprise. I've created a Library of functions called Pal (link to forum post) which quality is up to the AutoIt community standard as counterpart to the Peace program code.
    I want to state here that AutoIt is a mature program language as Peace obviously shows. I wish it to be used more extensively for professional or semi-professional apps. In my view AutoIt deserves a place amongst the major programming languages for Windows computers.
    Regards,
    Peter Verbeek








  3. Like
    user4157124 got a reaction from coffeeturtle in AutoIt error logger (AUERLO) UDF   
    File- and stdout/-err (console) output of messages, regular- and COM Object errors, exit method and -code, etc.
    Just call _AUERLO_Log() after to be logged functions (no parameters required if preceding function returns @error on failure). Or replace ConsoleWrite() (and SciTE trace lines) by _AUERLO_Log() for existing scripts. _AUERLO_FileRead() and _AUERLO_View() to display error log file contents (or import as CSV file to Microsoft Excel for example). Register custom functions to adjust date/time format and replace or add output functionality (no UDF source code modifications required). Output to: file console (stdout and stderr) non-blocking notification (Beep(), SoundPlay(), etc.) prompt (GUI dialog; script-halting notification) Microsoft Windows Event Log custom (register function) Download:
    AUERLO v2.0.0 Remarks:
    AutoIt v3.3.14.3+ required. @ScriptLineNumber = 0 if from callback (like $AUERLO_OPT_FUNCEXIT, except for $AUERLO_OPT_FUNCCOM = Default), -1 if @compiled. Generates Au3Stripper warnings (to be ignored without consequence; #AutoIt3Wrapper_Au3stripper_OnError=ForceUse -safe). agpl-3.0 auerlo.au3 :
    _AUERLO_Set() _AUERLO_Log() _AUERLO_LogAlt() _AUERLO_LogWinAPI() _AUERLO_LogEnv() _AUERLO_Assert() _AUERLO_FileClear() _AUERLO_FileRead() _AUERLO_View() auerloConstants.au3 :
    $AUERLO_LVL__ENUM - debug levels, $AUERLO_OPT__ENUM - _AUERLO_Set() options, $AUERLO_RET__ENUM - Return codes, $AUERLO_ERR__ENUM - @error codes, and $AUERLO_ATR__ENUM - error item attributes. Usage explanation:
    If @error signifies failure (implicit logging) : _ArrayDisplay($sNotAnArray); Returns @error = 1. _AUERLO_Log() ; Logs as $AUERLO_LVL_TRACE, $AUERLO_LVL_ERROR on @error, $AUERLO_LVL_DEBUG on @extended. If @error Then ... ; _AUERLO_Log() transparently passes @error and @extended from _ArrayDisplay(). If return value signifies failure (explicit logging) : If FileExists('invalid path') = 0 Then _AUERLO_Log('', $AUERLO_LVL_ERROR) Global $g_hFile = FileOpen('invalid path') If $g_hFile = -1 Then _AUERLO_Log('', $AUERLO_LVL_ERROR) If (return) value or expression result signifies failure (implicit logging): Global $g_hFile = FileOpen('invalid path') _AUERLO_Assert(Not ($g_hFile = -1)) ; $AUERLO_LVL_DEBUG if True (success), $AUERLO_LVL_WARNING if False. _AUERLO_Assert(FileWrite($g_hFile, 'data')); Successfull return value (1) evaluates to True; failure (0) to False. _AUERLO_Assert(IsArray($g_sNotAnArray)) Import error log file contents: Global $g_aArray2D = _AUERLO_FileRead(); Reads from current error log file. _AUERLO_View($g_aArray2D) Configuration ($AUERLO_OPT__ENUM in auerloConstants.au3 for description of all options) : _AUERLO_Set($AUERLO_OPT_LOGFILE, False) ; Disables output to error log file. _AUERLO_Set($AUERLO_OPT_LOGSTD, True) ; Enables output to stdout/stderr (console). _AUERLO_Set($AUERLO_OPT_FNCEXIT, Default) ; Registers default exit handler (no script exit logging without). _AUERLO_Set($AUERLO_OPT_FNCEXIT, Null) ; Deregisters default exit handler. _AUERLO_Set($AUERLO_OPT_FNCCOM, Default) ; Registers default COM Object error handler (no COM error logging without). _AUERLO_Set($AUERLO_OPT_FNCCOM, Null) ; Deregisters COM Object error handler. _AUERLO_Set($AUERLO_OPT_FNCCOM, YourFunc); Registers custom COM Object error handler YourFunc().  
  4. Like
    user4157124 reacted to jvanegmond in Simple Logging UDF - Log.au3 based on log4j / NLog   
    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 release
  5. Like
    user4157124 reacted to mLipok in ErrorLog.au3 UDF - A logging Library   
    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 complete
     
  6. Like
    user4157124 reacted to Danyfirex in Loga - A logging Library   
    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.
     
    Saludos
     
     
     
     
  7. Like
    user4157124 reacted to zorphnog in log4a - A logging UDF   
    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.au3
  8. Like
    user4157124 got a reaction from Earthshine in AutoIt error logger (AUERLO) UDF   
    File- and stdout/-err (console) output of messages, regular- and COM Object errors, exit method and -code, etc.
    Just call _AUERLO_Log() after to be logged functions (no parameters required if preceding function returns @error on failure). Or replace ConsoleWrite() (and SciTE trace lines) by _AUERLO_Log() for existing scripts. _AUERLO_FileRead() and _AUERLO_View() to display error log file contents (or import as CSV file to Microsoft Excel for example). Register custom functions to adjust date/time format and replace or add output functionality (no UDF source code modifications required). Output to: file console (stdout and stderr) non-blocking notification (Beep(), SoundPlay(), etc.) prompt (GUI dialog; script-halting notification) Microsoft Windows Event Log custom (register function) Download:
    AUERLO v2.0.0 Remarks:
    AutoIt v3.3.14.3+ required. @ScriptLineNumber = 0 if from callback (like $AUERLO_OPT_FUNCEXIT, except for $AUERLO_OPT_FUNCCOM = Default), -1 if @compiled. Generates Au3Stripper warnings (to be ignored without consequence; #AutoIt3Wrapper_Au3stripper_OnError=ForceUse -safe). agpl-3.0 auerlo.au3 :
    _AUERLO_Set() _AUERLO_Log() _AUERLO_LogAlt() _AUERLO_LogWinAPI() _AUERLO_LogEnv() _AUERLO_Assert() _AUERLO_FileClear() _AUERLO_FileRead() _AUERLO_View() auerloConstants.au3 :
    $AUERLO_LVL__ENUM - debug levels, $AUERLO_OPT__ENUM - _AUERLO_Set() options, $AUERLO_RET__ENUM - Return codes, $AUERLO_ERR__ENUM - @error codes, and $AUERLO_ATR__ENUM - error item attributes. Usage explanation:
    If @error signifies failure (implicit logging) : _ArrayDisplay($sNotAnArray); Returns @error = 1. _AUERLO_Log() ; Logs as $AUERLO_LVL_TRACE, $AUERLO_LVL_ERROR on @error, $AUERLO_LVL_DEBUG on @extended. If @error Then ... ; _AUERLO_Log() transparently passes @error and @extended from _ArrayDisplay(). If return value signifies failure (explicit logging) : If FileExists('invalid path') = 0 Then _AUERLO_Log('', $AUERLO_LVL_ERROR) Global $g_hFile = FileOpen('invalid path') If $g_hFile = -1 Then _AUERLO_Log('', $AUERLO_LVL_ERROR) If (return) value or expression result signifies failure (implicit logging): Global $g_hFile = FileOpen('invalid path') _AUERLO_Assert(Not ($g_hFile = -1)) ; $AUERLO_LVL_DEBUG if True (success), $AUERLO_LVL_WARNING if False. _AUERLO_Assert(FileWrite($g_hFile, 'data')); Successfull return value (1) evaluates to True; failure (0) to False. _AUERLO_Assert(IsArray($g_sNotAnArray)) Import error log file contents: Global $g_aArray2D = _AUERLO_FileRead(); Reads from current error log file. _AUERLO_View($g_aArray2D) Configuration ($AUERLO_OPT__ENUM in auerloConstants.au3 for description of all options) : _AUERLO_Set($AUERLO_OPT_LOGFILE, False) ; Disables output to error log file. _AUERLO_Set($AUERLO_OPT_LOGSTD, True) ; Enables output to stdout/stderr (console). _AUERLO_Set($AUERLO_OPT_FNCEXIT, Default) ; Registers default exit handler (no script exit logging without). _AUERLO_Set($AUERLO_OPT_FNCEXIT, Null) ; Deregisters default exit handler. _AUERLO_Set($AUERLO_OPT_FNCCOM, Default) ; Registers default COM Object error handler (no COM error logging without). _AUERLO_Set($AUERLO_OPT_FNCCOM, Null) ; Deregisters COM Object error handler. _AUERLO_Set($AUERLO_OPT_FNCCOM, YourFunc); Registers custom COM Object error handler YourFunc().  
  9. Like
    user4157124 reacted to Xandy in MapIt Quest   
    What's new section:
    Snowman_Sky is game using MapIt engine.  MapIt will evolve here for a little bit.
    Download: [ http://songersoft.com/programming/Snowman_Sky.zip ]
    Video demonstrating new sprite_sheet class and weather effect.
    Working on the Class section of the Character Sheet.
    Which is what makes multiclassing possible.

    Changing the value of Class will load the stored value for XP.  Lvl will be updated to the XP tier.
    Hit points are then rolled for each level of all learned classes.  Hit dice are specific to each class and a Constitution modifier is added to each roll of hit die.
     
  10. Like
    user4157124 reacted to EmilyLove in [UDF] Rollbar Error Reporting v0.2   
    Updated to v0.2
    Now aligned with UDF best practices!
    This update contains massive script breaking changes.
    Added:
    Multilingual support. See #CONSTANTS# section.
    Note: I won't be able to provide translations. Changed/Fixed:
    All functions and variables have been renamed to align with UDF best practices.  
    RollbarSDK.au3 RollbarTest.au3
  11. Like
    user4157124 reacted to Sidley in GDI+ Gauges   
    The code above has an error in the parameter order. Sorry about that, this should make it look less like an acid trip 😀
    #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=Gauges With Sliders.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstants.au3> #include <GDIplus.au3> #include <ColorConstants.au3> #include <Array.au3> Global Const $width = @DesktopWidth * 3 / 4 Global Const $height = @DesktopHeight Global $title = "GDI+" ; Build your GUI here Opt("GUIOnEventMode", 1) Global $hwnd = GUICreate($title, @DesktopWidth, @DesktopHeight, -1, -1, $WS_SIZEBOX) GUISetOnEvent($GUI_EVENT_CLOSE, "close") GUISetState() #Region Sliders Global $VariableMaxValue = 100 Global $SecondaryMaxValue = 100 Global $VariableMinValue = 0 Global $HexLabel = GUICtrlCreateLabel("Hex Value: ", @DesktopWidth - 300, 50, 150, 20) GUICtrlSetColor($HexLabel, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $idSliderThick = GUICtrlCreateSlider(@DesktopWidth - 300, 100, 250, 20) GUICtrlSetLimit(-1, 240, 0) ; change min/max value GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $ThickLabel = GUICtrlCreateLabel("Thickness Value: " & GUICtrlRead($idSliderThick), @DesktopWidth - 300, 120, 150, 20) GUICtrlSetColor($ThickLabel, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $idSliderVal = GUICtrlCreateSlider(@DesktopWidth - 300, 150, 250, 20) GUICtrlSetLimit(-1, $VariableMaxValue, $VariableMinValue) ; change min/max value GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $ValLabel = GUICtrlCreateLabel("Variable Value: " & GUICtrlRead($idSliderVal), @DesktopWidth - 300, 170, 150, 20) GUICtrlSetColor($ValLabel, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $idSliderScale = GUICtrlCreateSlider(@DesktopWidth - 300, 200, 250, 20) GUICtrlSetLimit(-1, 20, 0) ; change min/max value GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $ScaleLabel = GUICtrlCreateLabel("Scale Value: " & (GUICtrlRead($idSliderScale) * .1), @DesktopWidth - 300, 220, 150, 20) GUICtrlSetColor($ScaleLabel, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $idStartAngleScale = GUICtrlCreateSlider(@DesktopWidth - 300, 250, 250, 20) GUICtrlSetLimit(-1, 360, 0) ; change min/max value GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $StartAngleLabel = GUICtrlCreateLabel("Angle Value: " & GUICtrlRead($idStartAngleScale), @DesktopWidth - 300, 270, 150, 20) GUICtrlSetColor($StartAngleLabel, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $idSweepScale = GUICtrlCreateSlider(@DesktopWidth - 300, 300, 250, 20) GUICtrlSetLimit(-1, 360, 0) ; change min/max value GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $SweepLabel = GUICtrlCreateLabel("Sweep Value: " & GUICtrlRead($idSweepScale), @DesktopWidth - 300, 320, 150, 20) GUICtrlSetColor($SweepLabel, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $idCheckmarksScale = GUICtrlCreateSlider(@DesktopWidth - 300, 350, 250, 20) GUICtrlSetLimit(-1, 20, 0) ; change min/max value GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $CheckmarkLabel = GUICtrlCreateLabel("No. of Checkmarks: " & GUICtrlRead($idCheckmarksScale), @DesktopWidth - 300, 370, 150, 20) GUICtrlSetColor($CheckmarkLabel, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $idVarMin = GUICtrlCreateSlider(@DesktopWidth - 300, 450, 250, 20) GUICtrlSetLimit(-1, 0, -50) ; change min/max value GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $MinLabel = GUICtrlCreateLabel("Min Value: " & GUICtrlRead($idVarMin), @DesktopWidth - 300, 470, 150, 20) GUICtrlSetColor($MinLabel, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $RadioGroup1 = GUICtrlCreateGroup("", @DesktopWidth - 300, 500, 200, 50) Global $clockwiseCtrl = GUICtrlCreateRadio("Clockwise", @DesktopWidth - 280, 520, 80, 20) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlSetColor(-1, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $antiClockwiseCtrl = GUICtrlCreateRadio("Anti-clockwise", @DesktopWidth - 200, 520, 85, 20) GUICtrlSetColor(-1, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $RadioGroup2 = GUICtrlCreateGroup("", @DesktopWidth - 300, 550, 200, 50) Global $RadialCtrl = GUICtrlCreateRadio("Radial", @DesktopWidth - 280, 570, 80, 20) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlSetColor(-1, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $SquareCtrl = GUICtrlCreateRadio("Linear", @DesktopWidth - 200, 570, 85, 20) GUICtrlSetColor(-1, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) GUICtrlSetData($idSliderThick, 35) GUICtrlSetData($idSliderScale, 10) GUICtrlSetData($idStartAngleScale, 180) GUICtrlSetData($idSweepScale, 180) GUICtrlSetData($idCheckmarksScale, 10) #EndRegion Sliders GUISetBkColor(0x303030) Global $aWindowSize = WinGetClientSize($hwnd) ; Load your GDI+ resources here: _GDIPlus_Startup() Global $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd) Global $bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics) Global $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap) While 1 _GDIPlus_GraphicsClear($backbuffer, 0xFF303030) Sleep(50) #Region Test Variables Global $Thickness = GUICtrlRead($idSliderThick) Global $Variable = GUICtrlRead($idSliderVal) Global $tValue = 0xFF000000 Global $rValue = 0x00FF0000 Global $gValue = BitShift((255 - (($Variable / $VariableMaxValue) * 255)), -8) Global $bValue = 0x00 Global $ScalingFactor = GUICtrlRead($idSliderScale) / 10 GUICtrlSetData($HexLabel, "Hex Value: " & HEX(BitOR($tValue, $rValue, $gValue, $bValue))) Global $PenColour = ("0x" & HEX(BitOR($tValue, $rValue, $gValue, $bValue))) GUICtrlSetData($ValLabel, "Variable Value: " & GUICtrlRead($idSliderVal)) GUICtrlSetData($ThickLabel, "Thickness Value: " & GUICtrlRead($idSliderThick)) GUICtrlSetData($ScaleLabel, "Scale Value: " & (GUICtrlRead($idSliderScale) * .1)) GUICtrlSetData($StartAngleLabel, "Angle Value: " & GUICtrlRead($idStartAngleScale)) GUICtrlSetData($SweepLabel, "Sweep Value: " & GUICtrlRead($idSweepScale)) GUICtrlSetData($CheckmarkLabel, "No. Of Checkmarks: " & GUICtrlRead($idCheckmarksScale)) GUICtrlSetData($MinLabel, "Min Value: " & GUICtrlRead($idVarMin)) GUICtrlSetLimit($idSliderVal, $VariableMaxValue, $VariableMinValue) Local $Radius = 300 If GUICtrlRead($clockwiseCtrl) = $GUI_CHECKED Then Local $Clockwise = True Else Local $Clockwise = False EndIf Local $StartAngle = GUICtrlRead($idStartAngleScale) Local $SweepAngle = GUICtrlRead($idSweepScale) Local $CentrePointX = 500 Local $CentrePointY = 500 Local $NoOfCheckmarks = GUICtrlRead($idCheckmarksScale) Local $CheckLength = 15 Local $AllowedLimit = 75 Local $VariableLimit = True Local $VariableMinValue = GUICtrlRead($idVarMin) #EndRegion Test Variables #Region Function Call If GUICtrlRead($RadialCtrl) = $GUI_CHECKED Then _GDIPlus_GraphicsDrawPath($backbuffer, _Gauges_DrawRadialGauge($backbuffer, $CentrePointX, $CentrePointY, $Radius, $Thickness, $Variable, $ScalingFactor, $Clockwise, $StartAngle, $SweepAngle, $NoOfCheckmarks, $CheckLength, $VariableMaxValue, $VariableLimit, $AllowedLimit, $VariableMinValue)) GUICtrlSetState($idSliderThick, $GUI_SHOW) GUICtrlSetState($ThickLabel, $GUI_SHOW) GUICtrlSetState($idStartAngleScale, $GUI_SHOW) GUICtrlSetState($StartAngleLabel, $GUI_SHOW) GUICtrlSetState($idSweepScale, $GUI_SHOW) GUICtrlSetState($SweepLabel, $GUI_SHOW) GUICtrlSetState($RadioGroup1, $GUI_SHOW) GUICtrlSetState($clockwiseCtrl, $GUI_SHOW) GUICtrlSetState($antiClockwiseCtrl, $GUI_SHOW) Else _GDIPlus_GraphicsDrawPath($backbuffer, _Gauges_DrawLinearGauge($backbuffer, $CentrePointX, $CentrePointY, 600, 100, $Variable, $ScalingFactor, $NoOfCheckmarks, $CheckLength, $VariableMaxValue, $VariableLimit, $AllowedLimit, $VariableMinValue)) GUICtrlSetState($idSliderThick, $GUI_HIDE) GUICtrlSetState($ThickLabel, $GUI_HIDE) GUICtrlSetState($idStartAngleScale, $GUI_HIDE) GUICtrlSetState($StartAngleLabel, $GUI_HIDE) GUICtrlSetState($idSweepScale, $GUI_HIDE) GUICtrlSetState($SweepLabel, $GUI_HIDE) GUICtrlSetState($RadioGroup1, $GUI_HIDE) GUICtrlSetState($clockwiseCtrl, $GUI_HIDE) GUICtrlSetState($antiClockwiseCtrl, $GUI_HIDE) EndIf #EndRegion Function Call _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height) WEnd Func close() _GDIPlus_GraphicsDispose($backbuffer) _GDIPlus_BitmapDispose($bitmap) _GDIPlus_GraphicsDispose($graphics) _GDIPlus_Shutdown() Exit EndFunc ;==>close #Region Functions #Region Draw Linear Gauge ; #FUNCTION# ==================================================================================================================== ; Name...........: _Gauges_DrawLinearGauge ; Description ...: Creates a horizontal or vertical gauge in the graphics backbuffer ; Syntax.........: _Gauges_DrawLinearGauge(ByRef $backbuffer, $CentrePointX, $CentrePointY, $GaugeWidth, $GaugeHeight, $Variable, [$ScalingFactor = 1, [$NoOfCheckmarks = 6, [$CheckLength = 20, ; + [$VariableMaxValue = 256, [$VariableLimit = False, [$AllowedLimit = 0, [$VariableMinValue = 0]]]]]]] ) ; Parameters ....: $backbuffer - [byref] The graphics object to draw the gauge to. ; $CentrePointX - The horizontal coordinate of the centre of the gauge. ; $CentrePointY - The vertical coordinate of the centre of the gauge. ; $GaugeWidth - The width of the gauge (Duh). ; $GaugeHeight - The height of the gauge. ; $Variable - The variable used to change the gauge. ; $ScalingFactor - [optional] Scales the gauge by this factor. Default is 1, i.e. no scaling. ; $NoOfCheckmarks - [optional] The number of dashes indicating a scale around the gauge. Default is 6. ; $CheckLength - [optional] The length of the checkmarks in pixels. Default is 20. ; $VariableMaxValue - [optional] The maximum value of the variable. Default is 256. ; $VariableLimit - [optional] Boolean, if TRUE, displays a red limit indicator on the scale. Default is FALSE. ; $AllowedLimit -[optional] The value of the above limit if it is drawn. Default is 0. ; $VariableMinValue -[optional] The minimum value of the variable. Only used if negative numbers are required. Default is 0. ; Author ........: Simon Renardson (Sidley) ; Modified.......: ; Remarks .......: There is a more comprehensive function available, but I deemed it overkill for the majority of people. ; Related .......: _GDIPlus_ ; Example .......: Yes ; =============================================================================================================================== ;Draw a Linear gauge to the screen Func _Gauges_DrawLinearGauge(ByRef $backbuffer, $CentrePointX, $CentrePointY, $GaugeWidth, $GaugeHeight, $Variable, $ScalingFactor = 1, $NoOfCheckmarks = 6, $CheckLength = 20, $VariableMaxValue = 256, $VariableLimit = False, $AllowedLimit = 0, $VariableMinValue = 0) If $Variable >= 0 Then Local $BrushColour = ("0xFF4BF221") Else Local $BrushColour = ("0xFFFF0000") EndIf If $GaugeWidth >= $GaugeHeight Then Local $GaugeBrush = _GDIPlus_HatchBrushCreate(1, 0x00000000, $BrushColour) ;Set to vertical hatch if the gauge is horizontal Else Local $GaugeBrush = _GDIPlus_HatchBrushCreate(0, 0x00000000, $BrushColour) ;Set to horizontal hatch if the gauge is vertical EndIf Local $TextBrush = _GDIPlus_BrushCreateSolid($BrushColour) Local $Path = _GDIPlus_PathCreate() Local $hPen = _GDIPlus_PenCreate("0xFF96A29F", 2 * $ScalingFactor) ; Off-white pen for outlines Local $AllowedPen = _GDIPlus_PenCreate("0xFFFF0000", 8 * $ScalingFactor) ;Red pen for allowed speed indicators If $GaugeWidth >= $GaugeHeight Then ;If the gauge is to be length wise _GDIPlus_PathAddLine($Path, $CentrePointX - ((($GaugeWidth / 2) + $VariableMinValue * ($GaugeWidth / ($VariableMaxValue - $VariableMinValue))) * $ScalingFactor), ($CentrePointY + ($GaugeHeight / 2) * $ScalingFactor), $CentrePointX - ((($GaugeWidth / 2) + $VariableMinValue * ($GaugeWidth / ($VariableMaxValue - $VariableMinValue))) * $ScalingFactor) + ($Variable * ($GaugeWidth / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor), ($CentrePointY + ($GaugeHeight / 2) * $ScalingFactor)) _GDIPlus_PathAddLine($Path, $CentrePointX - ((($GaugeWidth / 2) + $VariableMinValue * ($GaugeWidth / ($VariableMaxValue - $VariableMinValue))) * $ScalingFactor) + ($Variable * ($GaugeWidth / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor), ($CentrePointY - ($GaugeHeight / 2) * $ScalingFactor), $CentrePointX - ((($GaugeWidth / 2) + $VariableMinValue * ($GaugeWidth / ($VariableMaxValue - $VariableMinValue))) * $ScalingFactor), ($CentrePointY - ($GaugeHeight / 2) * $ScalingFactor)) _GDIPlus_PathCloseFigure($Path) Else ;If the gauge is to be height wise _GDIPlus_PathAddLine($Path, ($CentrePointX + ($GaugeWidth / 2) * $ScalingFactor), ($CentrePointY + (($GaugeHeight / 2) * $ScalingFactor)) + ($VariableMinValue * ($GaugeHeight / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor), ($CentrePointX + ($GaugeWidth / 2) * $ScalingFactor), ($CentrePointY + (($GaugeHeight / 2) * $ScalingFactor)) + ($VariableMinValue * ($GaugeHeight / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor) - $Variable * ($GaugeHeight / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor) _GDIPlus_PathAddLine($Path, ($CentrePointX - ($GaugeWidth / 2) * $ScalingFactor), ($CentrePointY + (($GaugeHeight / 2) * $ScalingFactor)) + ($VariableMinValue * ($GaugeHeight / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor) - $Variable * ($GaugeHeight / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor, ($CentrePointX - ($GaugeWidth / 2) * $ScalingFactor), ($CentrePointY + (($GaugeHeight / 2) * $ScalingFactor)) + ($VariableMinValue * ($GaugeHeight / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor)) _GDIPlus_PathCloseFigure($Path) EndIf _GDIPlus_GraphicsFillPath($backbuffer, $Path, $GaugeBrush) ;Draw the gauge _DrawBar($backbuffer, $CentrePointX, $CentrePointY, $GaugeWidth, $GaugeHeight, $VariableMaxValue, $VariableMinValue, $hPen, $ScalingFactor) ;Draw the outline for the gauge _DrawLinearGaugeCheckMarks($backbuffer, $CentrePointX, $CentrePointY, $GaugeWidth, $GaugeHeight, $ScalingFactor, $VariableMaxValue, $NoOfCheckmarks, $CheckLength, $hPen) ;Draw the checkmarks for the gauge If $VariableLimit Then _DrawLinearAllowedSpeed($backbuffer, $CentrePointX, $CentrePointY, $GaugeWidth, $GaugeHeight, $VariableMaxValue, $AllowedLimit, $AllowedPen, $ScalingFactor, $VariableLimit) ;Draw the allowed speed indicator(s) for the gauge EndIf _LinearGaugeText($backbuffer, $Variable, $CentrePointX, $CentrePointY, $GaugeWidth, $GaugeHeight, $ScalingFactor, $TextBrush) ;Put the gauge text above the gauge _GDIPlus_PathDispose($Path) ;Tidy up _GDIPlus_BrushDispose($GaugeBrush) _GDIPlus_PenDispose($hPen) _GDIPlus_PenDispose($AllowedPen) _GDIPlus_BrushDispose($TextBrush) EndFunc ;==>_DrawLinearGauge ;Draw the text for the main gauge Func _LinearGaugeText(ByRef $backbuffer, $Variable, $CentrePointX, $CentrePointY, $GaugeWidth, $GaugeHeight, $ScalingFactor, ByRef $TextBrush) Local $FontSize = 80 * $ScalingFactor ;Linear gauge font size Local $Path = _GDIPlus_PathCreate() Local $Format = _GDIPlus_StringFormatCreate() Local $Family = _GDIPlus_FontFamilyCreate("Agency FB") ;Centre text font Local $Font = _GDIPlus_FontCreate($Family, $FontSize, 2) _GDIPlus_StringFormatSetAlign($Format, 2) ;Right align _GDIPlus_GraphicsSetSmoothingMode($backbuffer, 2) ;Change smoothing mode for text If $GaugeWidth >= $GaugeHeight Then Local $Layout = _GDIPlus_RectFCreate($CentrePointX - ($FontSize * $ScalingFactor / 2), $CentrePointY - ($GaugeHeight / 2 * $ScalingFactor) - $FontSize * 1.5 * $ScalingFactor) ;Set text position for inner text Else Local $Layout = _GDIPlus_RectFCreate($CentrePointX - ($GaugeWidth / 2) * $ScalingFactor - $FontSize * 2, ($CentrePointY - $FontSize * $ScalingFactor / 2)) ;Set text positionfor inner text EndIf _GDIPlus_PathAddString($Path, $Variable, $Layout, $Family, 0, $FontSize * $ScalingFactor) _GDIPlus_GraphicsFillPath($backbuffer, $Path, $TextBrush) $Layout = 0 _GDIPlus_PathDispose($Path) _GDIPlus_FontDispose($Font) _GDIPlus_StringFormatDispose($Format) _GDIPlus_FontFamilyDispose($Family) EndFunc ;==>_LinearGaugeText ;Draw the outline of the gauge Func _DrawBar(ByRef $backbuffer, $CentrePointX, $CentrePointY, $GaugeWidth, $GaugeHeight, $VariableMaxValue, $VariableMinValue, ByRef $hPen, $ScalingFactor = 1) Local $Path = _GDIPlus_PathCreate() _GDIPlus_PathAddLine($Path, $CentrePointX - ($GaugeWidth / 2) * $ScalingFactor, $CentrePointY - ($GaugeHeight / 2) * $ScalingFactor, $CentrePointX + ($GaugeWidth / 2) * $ScalingFactor, $CentrePointY - ($GaugeHeight / 2) * $ScalingFactor) _GDIPlus_PathAddLine($Path, $CentrePointX + ($GaugeWidth / 2) * $ScalingFactor, $CentrePointY + ($GaugeHeight / 2) * $ScalingFactor, $CentrePointX - ($GaugeWidth / 2) * $ScalingFactor, $CentrePointY + ($GaugeHeight / 2) * $ScalingFactor) _GDIPlus_PathCloseFigure($Path) If $GaugeWidth >= $GaugeHeight Then _GDIPlus_GraphicsDrawLine($backbuffer, $CentrePointX - ($GaugeWidth / 2 * $ScalingFactor) - $VariableMinValue * ($GaugeWidth / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor, $CentrePointY - ($GaugeHeight / 2) * $ScalingFactor, $CentrePointX - ($GaugeWidth / 2 * $ScalingFactor) - $VariableMinValue * ($GaugeWidth / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor, $CentrePointY + ($GaugeHeight / 2) * $ScalingFactor, $hPen) Else _GDIPlus_GraphicsDrawLine($backbuffer, $CentrePointX - ($GaugeWidth / 2 * $ScalingFactor), ($CentrePointY + (($GaugeHeight / 2) * $ScalingFactor)) + ($VariableMinValue * ($GaugeHeight / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor), $CentrePointX + ($GaugeWidth / 2 * $ScalingFactor), ($CentrePointY + (($GaugeHeight / 2) * $ScalingFactor)) + ($VariableMinValue * ($GaugeHeight / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor), $hPen) EndIf _GDIPlus_GraphicsDrawPath($backbuffer, $Path, $hPen) ;Draw the outline _GDIPlus_PathDispose($Path) EndFunc ;==>_DrawBar ;Draw the checkmarks Func _DrawLinearGaugeCheckMarks(ByRef $backbuffer, $CentrePointX, $CentrePointY, $GaugeWidth, $GaugeHeight, $ScalingFactor, $VariableMaxValue, $NoOfCheckmarks, $CheckLength, ByRef $hPen) Local $TextBrush = _GDIPlus_BrushCreateSolid("0xFFFFFFFF") ;Solid white brush for the checkmarks Local $aPoints[$NoOfCheckmarks][2] ;Two cartesian coordinates for each checkmark Local $aMarkText[$NoOfCheckmarks] ; The text for each checkmark ;Create the font for the checkmarks Local $FontSize = 15 * $ScalingFactor ;The font size (Scaled) Local $Format = _GDIPlus_StringFormatCreate() Local $Family = _GDIPlus_FontFamilyCreate("Agency FB") Local $Font = _GDIPlus_FontCreate($Family, $FontSize, 2) For $i = 0 to($NoOfCheckmarks - 1) $aMarkText[$i] = Round($VariableMinValue + (($VariableMaxValue - $VariableMinValue) / ($NoOfCheckmarks - 1)) * $i) Next If $GaugeWidth >= $GaugeHeight Then _GDIPlus_GraphicsDrawLine($backbuffer, $CentrePointX - ($GaugeWidth / 2) * $ScalingFactor, $CentrePointY - ($GaugeHeight / 2 + 10) * $ScalingFactor, $CentrePointX + ($GaugeWidth / 2) * $ScalingFactor, $CentrePointY - ($GaugeHeight / 2 + 10) * $ScalingFactor, $hPen) For $i = 0 to($NoOfCheckmarks - 1) ;Set the coordinates of each checkmark $aPoints[$i][0] = ($CentrePointX - ($GaugeWidth / 2) * $ScalingFactor) + ($GaugeWidth * $ScalingFactor / ($NoOfCheckmarks - 1)) * $i ;Set x position depending on the number of checkmarks and the length of the gauge $aPoints[$i][1] = $CentrePointY - ($GaugeHeight / 2 + 10) * $ScalingFactor ;Height remains uniform Next For $i = 0 to($NoOfCheckmarks - 1) _GDIPlus_GraphicsDrawLine($backbuffer, $aPoints[$i][0], $aPoints[$i][1], $aPoints[$i][0], ($aPoints[$i][1] - $CheckLength * $ScalingFactor), $hPen) ;Draw a line $Checklength long $Layout = _GDIPlus_RectFCreate(($aPoints[$i][0] - $FontSize), ($aPoints[$i][1] - $CheckLength * $ScalingFactor - ($FontSize * 1.5) * $ScalingFactor), 0, 0) _GDIPlus_GraphicsDrawStringEx($backbuffer, $aMarkText[$i], $Font, $Layout, $Format, $TextBrush) ;Draw the sext for the checkmark Next Else _GDIPlus_GraphicsDrawLine($backbuffer, $CentrePointX - ($GaugeWidth / 2 * $ScalingFactor) - 10 * $ScalingFactor, $CentrePointY + ($GaugeHeight / 2) * $ScalingFactor, $CentrePointX - ($GaugeWidth / 2 * $ScalingFactor) - 10 * $ScalingFactor, $CentrePointY - ($GaugeHeight / 2) * $ScalingFactor, $hPen) For $i = 0 to($NoOfCheckmarks - 1) $aPoints[$i][0] = $CentrePointX - ($GaugeWidth / 2 + 10) * $ScalingFactor $aPoints[$i][1] = ($CentrePointY + ($GaugeHeight / 2) * $ScalingFactor) - ($GaugeHeight * $ScalingFactor / ($NoOfCheckmarks - 1)) * $i Next For $i = 0 to($NoOfCheckmarks - 1) _GDIPlus_GraphicsDrawLine($backbuffer, $aPoints[$i][0], $aPoints[$i][1], $aPoints[$i][0] - $CheckLength * $ScalingFactor, $aPoints[$i][1], $hPen) $Layout = _GDIPlus_RectFCreate(($aPoints[$i][0] - $CheckLength * $ScalingFactor - $FontSize * 2.5), $aPoints[$i][1] - $FontSize / 1.5, 0, 0) _GDIPlus_GraphicsDrawStringEx($backbuffer, $aMarkText[$i], $Font, $Layout, $Format, $TextBrush) Next EndIf $Layout = 0 _GDIPlus_BrushDispose($TextBrush) _GDIPlus_FontDispose($Font) _GDIPlus_StringFormatDispose($Format) _GDIPlus_FontFamilyDispose($Family) EndFunc ;==>_DrawLinearGaugeCheckMarks Func _DrawLinearAllowedSpeed(ByRef $backbuffer, $CentrePointX, $CentrePointY, $GaugeWidth, $GaugeHeight, $MaxValue, $AllowedLimit, ByRef $AllowedPen, $ScalingFactor, $PrimaryAllowedSpeed) Local $Path = _GDIPlus_PathCreate() If $PrimaryAllowedSpeed Then If $GaugeWidth >= $GaugeHeight Then _GDIPlus_PathAddLine($Path, $CentrePointX - ($GaugeWidth / 2) * $ScalingFactor, $CentrePointY - ($GaugeHeight / 2 + 15) * $ScalingFactor + 3 * $ScalingFactor, ($CentrePointX - (($GaugeWidth / 2) * $ScalingFactor)) + ($GaugeWidth * $AllowedLimit / 100 * $ScalingFactor), $CentrePointY - ($GaugeHeight / 2 + 15) * $ScalingFactor + 3 * $ScalingFactor) Else _GDIPlus_PathAddLine($Path, $CentrePointX - ($GaugeWidth / 2) * $ScalingFactor - 10 * $ScalingFactor, $CentrePointY + ($GaugeHeight / 2) * $ScalingFactor, $CentrePointX - ($GaugeWidth / 2) * $ScalingFactor - 10 * $ScalingFactor, ($CentrePointY + ($GaugeHeight / 2) * $ScalingFactor) - ($GaugeHeight * $AllowedLimit / 100 * $ScalingFactor)) EndIf EndIf _GDIPlus_GraphicsDrawPath($backbuffer, $Path, $AllowedPen) _GDIPlus_PathDispose($Path) EndFunc ;==>_DrawLinearAllowedSpeed #EndRegion Draw Linear Gauge #Region Draw Radial Gauge ; #FUNCTION# ==================================================================================================================== ; Name...........: _Gauges_DrawRadialGauge ; Description ...: Creates a radial gauge in the graphics backbuffer ; Syntax.........: _Gauges_DrawRadialGauge(ByRef $backbuffer, $CentrePointX, $CentrePointY, $Radius, $Thickness, $Variable, $ScalingFactor = 1, $Clockwise = True, $StartAngle = 0, ; + $SweepAngle = 180, $NoOfCheckmarks = 6, $CheckLength = 20, $VariableMaxValue = 256, $VariableLimit = True, $AllowedLimit = 0, $VariableMinValue = 0) ; Parameters ....: $backbuffer - [byref] The graphics object to draw the gauge to. ; $CentrePointX - The horizontal coordinate of the centre of the gauge. ; $CentrePointY - The vertical coordinate of the centre of the gauge. ; $Radius - The radius of the outer edge of the gauge. ; $Thickness - The thickness of the gauge in pixels. ; $Variable - The variable used to change the gauge. ; $ScalingFactor - [optional] Scales the gauge by this factor. Default is 1, i.e. no scaling. ; $Clockwise - [optional] Boolean, determines whether the gauge fills clockwise or anti-clockwise. Default is TRUE, i.e. clockwise. ; $StartAngle - [optional] The starting angle of the gauge. Default is 0 (East). ; $SweepAngle - [optional] The sweep angle of the gauge (How many degrees it rotates through). The default is 180. ; $NoOfCheckmarks - [optional] The number of dashes indicating a scale around the gauge. Default is 6. ; $CheckLength - [optional] The length of the checkmarks in pixels. Default is 20. ; $VariableMaxValue - [optional] The maximum value of the variable. Default is 256. ; $VariableLimit - [optional] Boolean, if TRUE, displays a red limit indicator on the scale. Default is FALSE. ; $AllowedLimit -[optional] The value of the above limit if it is drawn. Default is 0. ; $VariableMinValue -[optional] The minimum value of the variable. Only used if negative numbers are required. Default is 0. ; Author ........: Simon Renardson (Sidley) ; Modified.......: ; Remarks .......: There is a more comprehensive function available, but I deemed it overkill for the majority of people. ; Related .......: _GDIPlus_ ; Example .......: Yes ; =============================================================================================================================== ;Draw Gauge (Speed/Load Level) ;Creates Completed Radial Gauge ;~ _DrawRadialGauge($CentrePointX, $CentrePointY, $Radius, $Thickness, $Variable, [$ScalingFactor = 1, [$Clockwise = True, [$StartAngle = 0, [$SweepAngle = 180, [$MaxValue = 256, [$NoOfCheckmarks = 10, [$CheckLength = 20]]]]]]]) Func _Gauges_DrawRadialGauge(ByRef $backbuffer, $CentrePointX, $CentrePointY, $Radius, $Thickness, $Variable, $ScalingFactor = 1, $Clockwise = True, $StartAngle = 0, $SweepAngle = 180, $NoOfCheckmarks = 6, $CheckLength = 20, $VariableMaxValue = 256, $VariableLimit = True, $AllowedLimit = 0, $VariableMinValue = 0) Local $BrushColour = ("0x" & HEX(BitOR(0xFFFF0000, BitShift((255 - (($Variable / $VariableMaxValue) * 255)), -8)))) Local $GaugeBrush = _GDIPlus_HatchBrushCreate(39, 0xFF000000, $BrushColour) Local $TextBrush = _GDIPlus_BrushCreateSolid($BrushColour) Local $Path = _GDIPlus_PathCreate() Local $hPen = _GDIPlus_PenCreate("0xFF96A29F", 2 * $ScalingFactor) ;Pen colour Local $AllowedPen = _GDIPlus_PenCreate("0xFFFF0000", 10 * $ScalingFactor) _GDIPlus_GraphicsSetSmoothingMode($backbuffer, 2) ;TODO may need to be removed If $Clockwise Then ;If clockwise rotation _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), $StartAngle - $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue)), $Variable * $SweepAngle / ($VariableMaxValue - $VariableMinValue)) ;Add outer arc of gauge $Radius -= ($Thickness * $ScalingFactor) ;Reduce radius for inner arc by the thickness of the gauge _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), $StartAngle - $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue)) + ($Variable * $SweepAngle / ($VariableMaxValue - $VariableMinValue)), (-1 * $Variable * $SweepAngle / ($VariableMaxValue - $VariableMinValue))) ;Add inner arc of Gauge Else ;If anti-clockwise rotation _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), $StartAngle + $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue)), (-1 * $Variable * $SweepAngle / ($VariableMaxValue - $VariableMinValue))) ;Add outer arc of gauge $Radius -= ($Thickness * $ScalingFactor) ;Reduce radius for inner arcby the thickness of the gauge _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), $StartAngle + $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue)) - ($Variable * $SweepAngle / ($VariableMaxValue - $VariableMinValue)), $Variable * $SweepAngle / ($VariableMaxValue - $VariableMinValue)) ;Add inner arc of Gauge EndIf $Radius += ($Thickness * $ScalingFactor) ;Return radius to original size _GDIPlus_PathCloseFigure($Path) ;Close the two arcs _GDIPlus_GraphicsFillPath($backbuffer, $Path, $GaugeBrush) ;Fill the gauge and centre text with colour _DrawRadialGaugeText($backbuffer, $Variable, $CentrePointX, $CentrePointY, $Clockwise, $Radius, $ScalingFactor, $TextBrush) ;Draw the centre text _DrawGaugeOutline($backbuffer, $CentrePointX, $CentrePointY, $Radius, $VariableMaxValue, $VariableMinValue, $Thickness, $ScalingFactor, $Clockwise, $StartAngle, $SweepAngle, $hPen) ;Draw the gauge outline _DrawIndicators($backbuffer, $CentrePointX, $CentrePointY, $Radius, $Thickness, $Clockwise, $ScalingFactor, $StartAngle, $SweepAngle, $hPen, True) ;Draw scale arc _DrawCheckMarks($backbuffer, $CentrePointX, $CentrePointY, $Radius, $Thickness, $ScalingFactor, $VariableMaxValue, $NoOfCheckmarks, $CheckLength, $StartAngle, $SweepAngle, $hPen, True) ;Draw scale checkmarks If $VariableLimit Then _DrawRadialAllowedSpeed($backbuffer, $CentrePointX, $CentrePointY, $Radius, $Thickness, $Clockwise, $ScalingFactor, $StartAngle, $SweepAngle, $AllowedLimit, $AllowedPen, True) ;Draw allowed speed limits EndIf _GDIPlus_PathDispose($Path) ;Tidy up _GDIPlus_BrushDispose($GaugeBrush) _GDIPlus_BrushDispose($TextBrush) _GDIPlus_PenDispose($hPen) _GDIPlus_PenDispose($AllowedPen) EndFunc ;==>_DrawRadialGauge ;Draw Variable Value (Text, Load/Speed Value) ;Creates The Centre Text of the Radial Gauge ;~ Func _DrawRadialGaugeText($ValueText, $CentrePointX, $CentrePointY, $Clockwise, $Radius, $ScalingFactor) Func _DrawRadialGaugeText(ByRef $backbuffer, $ValueText, $CentrePointX, $CentrePointY, $Clockwise, $Radius, $ScalingFactor, ByRef $TextBrush) Local $FontSize = 180 * $ScalingFactor ;Default font size (Scaled) Local $Text = _GDIPlus_PathCreate() Local $Format = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($Format, 2) ;Align right (Doesn't seem to make a difference) Local $Family = _GDIPlus_FontFamilyCreate("Agency FB") ;Centre text font Local $Font = _GDIPlus_FontCreate($Family, $FontSize, 2) Local $Layout = _GDIPlus_RectFCreate($CentrePointX - ($FontSize / 1.3) * $ScalingFactor, $CentrePointY - $FontSize * $ScalingFactor / 2) ;Set position (Top left) _GDIPlus_PathAddString($Text, Round($ValueText, 1), $Layout, $Family, 0, $FontSize * $ScalingFactor) ;Add value to path (To 1 decimal place) _GDIPlus_GraphicsFillPath($backbuffer, $Text, $TextBrush) $Layout = 0 ;Tidy up _GDIPlus_PathDispose($Text) _GDIPlus_FontDispose($Font) _GDIPlus_StringFormatDispose($Format) _GDIPlus_FontFamilyDispose($Family) EndFunc ;==>_DrawRadialGaugeText ;Draw Gauge Outline ;Creates the Outline of the Radial Gauge ;~ Func _DrawGaugeOutline($CentrePointX, $CentrePointY, $Radius, $Thickness, $ScalingFactor, $Clockwise, $StartAngle, $SweepAngle) Func _DrawGaugeOutline(ByRef $backbuffer, $CentrePointX, $CentrePointY, $Radius, $VariableMaxValue, $VariableMinValue, $Thickness, $ScalingFactor, $Clockwise, $StartAngle, $SweepAngle, ByRef $hPen) Local $Path = _GDIPlus_PathCreate() Local Const $PI = 3.141592653589793 $Radius += 2 ;Put the outline 2 px outside the gauge If $Clockwise Then ;If the gauge is to be filled clockwise _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), $StartAngle, $SweepAngle) _GDIPlus_GraphicsDrawLine($backbuffer, $CentrePointX + ($Radius * $ScalingFactor * Cos(($PI / 180) * ($StartAngle - $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue))))), $CentrePointY + ($Radius * $ScalingFactor * Sin(($PI / 180) * ($StartAngle - $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue))))), $CentrePointX + (($Radius - ($Thickness * $ScalingFactor) - (4 * $ScalingFactor)) * Cos(($PI / 180) * ($StartAngle - $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue)))) * $ScalingFactor), $CentrePointY + (($Radius - ($Thickness * $ScalingFactor) - 4) * $ScalingFactor * Sin(($PI / 180) * ($StartAngle - $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue))))), $hPen) $Radius -= ($Thickness * $ScalingFactor) ;Reduce radius for inner arc $Radius -= 4 _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), ($StartAngle + $SweepAngle), -$SweepAngle) Else _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), $StartAngle, -$SweepAngle) _GDIPlus_GraphicsDrawLine($backbuffer, $CentrePointX + ($Radius * $ScalingFactor * Cos(($PI / 180) * ($StartAngle + $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue))))), $CentrePointY + ($Radius * $ScalingFactor * Sin(($PI / 180) * ($StartAngle + $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue))))), $CentrePointX + (($Radius - ($Thickness * $ScalingFactor) - (4 * $ScalingFactor)) * Cos(($PI / 180) * ($StartAngle + $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue)))) * $ScalingFactor), $CentrePointY + (($Radius - ($Thickness * $ScalingFactor) - 4) * $ScalingFactor * Sin(($PI / 180) * ($StartAngle + $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue))))), $hPen) $Radius -= ($Thickness * $ScalingFactor) ;Reduce radius for inner arc $Radius -= 4 _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), $StartAngle - $SweepAngle, $SweepAngle) EndIf _GDIPlus_PathCloseFigure($Path) ;Close the path _GDIPlus_GraphicsDrawPath($backbuffer, $Path, $hPen) ;Draw the path _GDIPlus_PathDispose($Path) EndFunc ;==>_DrawGaugeOutline ;Draw Scale(s) ;Creates a number of indicative markings around the centre of the radial gauge ;~ Func _DrawIndicators($CentrePointX, $CentrePointY, $Radius, $Thickness, $Clockwise, $ScalingFactor, $StartAngle, $SweepAngle) Func _DrawIndicators(ByRef $backbuffer, $CentrePointX, $CentrePointY, $Radius, $Thickness, $Clockwise, $ScalingFactor, $StartAngle, $SweepAngle, ByRef $hPen, $Inside) Local $Path = _GDIPlus_PathCreate() $Radius -= ($Thickness + 20) * $ScalingFactor If $Clockwise Then _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), $StartAngle, $SweepAngle) Else ;Doesn't make much difference, but it will be 180 degrees out _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), $StartAngle, -$SweepAngle) EndIf _GDIPlus_GraphicsDrawPath($backbuffer, $Path, $hPen) _GDIPlus_PathDispose($Path) EndFunc ;==>_DrawIndicators ;Draw the allowed speed marker Func _DrawRadialAllowedSpeed(ByRef $backbuffer, $CentrePointX, $CentrePointY, $Radius, $Thickness, $Clockwise, $ScalingFactor, $StartAngle, $SweepAngle, _ $AllowedLimit, ByRef $AllowedPen, $Inside) Local $Path = _GDIPlus_PathCreate() $Radius -= ($Thickness + 24) * $ScalingFactor If $Clockwise Then ;Display in a clockwise direction _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), $StartAngle, $SweepAngle * $AllowedLimit / 100) ElseIf NOT $Clockwise Then ;Display in an anti-clockwise direction _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), $StartAngle, -$SweepAngle * $AllowedLimit / 100) EndIf _GDIPlus_GraphicsDrawPath($backbuffer, $Path, $AllowedPen) ;Draw with the red pen ($AllowedPen) _GDIPlus_PathDispose($Path) EndFunc ;==>_DrawRadialAllowedSpeed ;DrawCheckmarks (Checkmarks) ;Creates the checkmarks and text around the indicator gauge ;~ Func _DrawCheckMarks($CentrePointX, $CentrePointY, $Radius, $Thickness, $ScalingFactor, $MaxValue, $NoOfCheckmarks, $CheckLength, $StartAngle, $SweepAngle, $hPen) Func _DrawCheckMarks(ByRef $backbuffer, $CentrePointX, $CentrePointY, $Radius, $Thickness, $ScalingFactor, $VariableMaxValue, $NoOfCheckmarks, $CheckLength, $StartAngle, _ $SweepAngle, ByRef $hPen, $Inside) Local Const $PI = 3.141592653589793 Local $TextBrush = _GDIPlus_BrushCreateSolid("0xFFFFFFFF") Local $aPoints[$NoOfCheckmarks][4] ;Creates an array of four points for each check line Local $aMarkText[$NoOfCheckmarks] ;Creates the text for the checkmarks $Radius -= ($Thickness + 20) * $ScalingFactor For $i = 0 to ($NoOfCheckmarks-1) $aMarkText[$i] = Round((($VariableMaxValue - $VariableMinValue) / ($NoOfCheckmarks - 1)) * $i) + $VariableMinValue ;Round checkmark values to one decimal place Next Local $aAngles[$NoOfCheckmarks] = [] ;Create an array to hold the angles at which the checkmarks should be If $Clockwise Then For $i = 0 to($NoOfCheckmarks - 1) $aAngles[$i] = $StartAngle + (($SweepAngle / ($NoOfCheckmarks - 1)) * $i) ;Spread out checkmarks evenly over the gauge Next Else ;For anticlockwise filling gauge For $i = 0 to($NoOfCheckmarks - 1) $aAngles[$i] = $StartAngle - (($SweepAngle / ($NoOfCheckmarks - 1)) * $i) ;Spread out checkmarks evenly over the gauge Next EndIf For $i = 0 to($NoOfCheckmarks - 1) $aAngles[$i] = $aAngles[$i] * $PI / 180 ;Convert degrees to radians $aPoints[$i][0] = $CentrePointX + ($Radius * Cos($aAngles[$i]) * $ScalingFactor) ;Create cartesian coordinates for the check lines from polar coordinates (Radius, angle) $aPoints[$i][1] = $CentrePointY + ($Radius * Sin($aAngles[$i]) * $ScalingFactor) $aPoints[$i][2] = $CentrePointX + (($Radius - ($CheckLength * $ScalingFactor)) * Cos($aAngles[$i]) * $ScalingFactor) $aPoints[$i][3] = $CentrePointY + (($Radius - ($CheckLength * $ScalingFactor)) * Sin($aAngles[$i]) * $ScalingFactor) Next ;Font data for checkmark text Local $Format = _GDIPlus_StringFormatCreate() Local $Family = _GDIPlus_FontFamilyCreate("Agency FB") Local $FontSize = 15 Local $Font = _GDIPlus_FontCreate($Family, $FontSize * $ScalingFactor, 2) For $i = 0 to($NoOfCheckmarks - 1) ;For each checkmark _GDIPlus_GraphicsDrawLine($backbuffer, $aPoints[$i][0], $aPoints[$i][1], $aPoints[$i][2], $aPoints[$i][3], $hPen) ;Draw the lines $Layout = _GDIPlus_RectFCreate($aPoints[$i][2] - ($FontSize * Cos($aAngles[$i])) - (18 * $ScalingFactor), $aPoints[$i][3] - ($FontSize * Sin($aAngles[$i]) + 10), 0, 0) _GDIPlus_GraphicsDrawStringEx($backbuffer, $aMarkText[$i], $Font, $Layout, $Format, $TextBrush) Next $Layout = 0 _GDIPlus_BrushDispose($TextBrush) _GDIPlus_FontDispose($Font) _GDIPlus_StringFormatDispose($Format) _GDIPlus_FontFamilyDispose($Family) EndFunc ;==>_DrawCheckMarks #EndRegion Draw Radial Gauge #EndRegion Functions  
  12. Like
    user4157124 reacted to TheDcoder in Process UDF, Get both the output & the exit code!   
    Hello Everyone , Are you tired of searching the forum for getting both the exit code & the stdout output? Then you are in the right place!

    With this UDF you can get the both output & exit code of the command or the console app! Or you can get the exit code of another process without having to use RunWait...
    Features:
    1. Simple & Lightweight (15 KB)
    2. Detailed comments & description
    3. Flexible functions with many optional parameters
    A BIG THANKS TO PsaltyDS for the functions! 2 of the (main) functions in the UDF are his work
     
    List of functions:
    Downloads:
    Grab the latest (in development) code from GitHub
     
    Hope it may help you, TD
     
    P.S Icon made by Freepik from www.flaticon.com, Modified by TheDcoder
  13. Like
    user4157124 reacted to scintilla4evr in Color Book (.ACB) Editor   
    Hello!
    One of the ways to easily access your own palette of colors in Photoshop is using Swatches. But:

    If you'd want to have them right in the color picker, you'd have to create a color book first. But how? Well, you can use a hex editor, but who has the time to do that?
    So, I decided to make a little tool to create color book files. And here it is:

    Features:
    Add, edit and save Color Books Save to Color Swatches Import INI files Export AU3 constants definitions and HTML files INI file formatting:
    [Colors] Name=Hex ; Example: ; Blue=0000FF Have fun!
    Color Book Editor
  14. Like
    user4157124 reacted to scintilla4evr in ColorEx UDF   
    Hello! I wrote a small UDF for converting and comparing colors and I'd like to share it with you.

    Features:
    Converting colors to CMYK, XYZ, CIE-L*ab and CIE-L*CH Calculating color harmonies Calculating delta value for colors (Delta C*, H* and E*) Lots of color constants (over 1900, including colors from Google Material Design and web colors) ColorEx UDF
  15. Like
    user4157124 reacted to scintilla4evr in Advanced Math UDF   
    I started writing this UDF a while ago, so I decided to share it here.
    This is an UDF full of advanced mathematical functions. It allows to work with primes, create number sequences, interpolate, calculate values of functions like Riemann zeta.
    Full list of functions:
     
    Changelog:
    Download
  16. Like
    user4157124 reacted to MattyD in Big Analogue Clock   
    Hey folks,
    This is actually the beginnings of something else - but I was pretty happy with how this part turned out.
    So hey, here is a clock.
    it is drag-able
    Escape (after clicking on clock) : Exit
    Wheel: Grow & Shrink
    Click Wheel: Reset Size
    Edit: somehow missed an include directive...
    #AutoIt3Wrapper_Au3Check_Parameters = -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #NoTrayIcon #include <GDIPlus.au3> #include <GUIConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Global $hGUI, $iWinH, $iWinW, $iChSize, _ $iStartSz, $iMargin, $iCanvasSz, $iWinXStartPos Global Const $PI = 4 * ATan(1) Global Const $MAGIC_PINK = 0xFF00FF, $MAGIC_PINK_ARGB = 0xFFFF00FF $iWinH = @DesktopHeight $iWinW = $iWinH $iCanvasSz = $iWinH $iMargin = 4 $iStartSz = Int($iWinH / 4) - (2 * $iMargin) $iWinXStartPos = 0 ;Right Side: ide@DesktopWidth - ($iStartSz + (2 * $iMargin)) $hGUI = GUICreate("Clock", $iWinW, $iWinH, $iWinXStartPos, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) GUISetBkColor($MAGIC_PINK) _WinAPI_SetLayeredWindowAttributes($hGUI, $MAGIC_PINK, 0xF0) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL") GUIRegisterMsg($WM_NCMBUTTONDOWN, "WM_NCMBUTTONDOWN") Clock() Func Clock() Local $hGraphic, $hClockBitmap, $hClockGraphic Local $iSize, $iDigSize, $iOrigin Local $iNumDist, $iDigXOffset, $iDigYOffset Local $ixOffset, $iyOffset Local $hFrameBrush, $hNoseBrush, $hHighlightBrush, $hFaceBrush Local $hBlackPen, $hSecPen, $hMinPen, $hHourPen Local $iSec, $iMin, $iHour Local $ixSecOffset, $iySecOffset, $ixMinOffset, $iyMinOffset, _ $ixHourOffset, $iyHourOffset $iDigSize = $iSize / 20 $iChSize = $iStartSz _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hClockBitmap = _GDIPlus_BitmapCreateFromGraphics($iCanvasSz, $iCanvasSz, $hGraphic) $hClockGraphic = _GDIPlus_ImageGetGraphicsContext($hClockBitmap) _GDIPlus_GraphicsSetSmoothingMode($hClockGraphic, 4) $hFrameBrush = _GDIPlus_BrushCreateSolid(0xFF80BBCC) $hNoseBrush = _GDIPlus_BrushCreateSolid(0xEE778888) $hHighlightBrush = _GDIPlus_BrushCreateSolid(0x44FF00FF) $hFaceBrush = _GDIPlus_BrushCreateSolid(0xFFEEF0FF) $hSecPen = _GDIPlus_PenCreate(0xBB882255, 1) $hMinPen = _GDIPlus_PenCreate(0xBBFF8833, 4) $hHourPen = _GDIPlus_PenCreate(0xEE4488AA, 5) $hBlackPen = _GDIPlus_PenCreate(0xFF000000, 4) Do If $iSize <> $iChSize Or @SEC <> $iSec Then $iSize = $iChSize $iDigSize = $iSize / 20 $iOrigin = Int($iSize / 2) + $iMargin $iNumDist = $iSize / 2 - ($iSize / 8) $iDigXOffset = .55 * $iDigSize $iDigYOffset = -(.7 * $iDigSize) _GDIPlus_GraphicsClear($hClockGraphic, $MAGIC_PINK_ARGB) _GDIPlus_GraphicsFillEllipse($hClockGraphic, $iMargin, $iMargin, $iSize, $iSize, $hFrameBrush) _GDIPlus_GraphicsFillEllipse($hClockGraphic, $iMargin + 8, $iMargin + 8, $iSize - 8, $iSize - 8, $hHighlightBrush) _GDIPlus_GraphicsFillEllipse($hClockGraphic, $iMargin + 8, $iMargin + 8, $iSize - 16, $iSize - 16, $hFaceBrush) _GDIPlus_GraphicsDrawEllipse($hClockGraphic, $iMargin, $iMargin, $iSize, $iSize, $hBlackPen) For $i = 1 To 12 $ixOffset = Int($iNumDist * Sin($i * ($PI / 6))) $iyOffset = Int($iNumDist * Cos($i * ($PI / 6))) $ixOffset -= (StringLen($i) * $iDigXOffset) $iyOffset -= $iDigYOffset _GDIPlus_GraphicsDrawString($hClockGraphic, $i, ($iOrigin + $ixOffset), ($iOrigin - $iyOffset), "Symbol", $iDigSize) Next $iSec = @SEC $iMin = 60 * @MIN + $iSec $iHour = (3600 * @HOUR) + $iMin $ixSecOffset = Int((0.83 * $iNumDist) * Sin($iSec * ($PI / 30))) $iySecOffset = Int((0.83 * $iNumDist) * Cos($iSec * ($PI / 30))) $ixMinOffset = Int((0.85 * $iNumDist) * Sin($iMin * ($PI / 1800))) $iyMinOffset = Int((0.85 * $iNumDist) * Cos($iMin * ($PI / 1800))) $ixHourOffset = Int((0.65 * $iNumDist) * Sin($iHour * ($PI / 21600))) $iyHourOffset = Int((0.65 * $iNumDist) * Cos($iHour * ($PI / 21600))) _GDIPlus_GraphicsDrawLine($hClockGraphic, $iOrigin, $iOrigin, $iOrigin + $ixHourOffset, $iOrigin - $iyHourOffset, $hHourPen) _GDIPlus_GraphicsDrawLine($hClockGraphic, $iOrigin, $iOrigin, $iOrigin + $ixMinOffset, $iOrigin - $iyMinOffset, $hMinPen) _GDIPlus_GraphicsDrawLine($hClockGraphic, $iOrigin, $iOrigin, $iOrigin + $ixSecOffset, $iOrigin - $iySecOffset, $hSecPen) _GDIPlus_GraphicsFillEllipse($hClockGraphic, $iOrigin - 3, $iOrigin - 3, 6, 6, $hNoseBrush) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hClockBitmap, 0, 0, $iCanvasSz, $iCanvasSz) EndIf Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_BrushDispose($hFrameBrush) _GDIPlus_BrushDispose($hNoseBrush) _GDIPlus_BrushDispose($hHighlightBrush) _GDIPlus_BrushDispose($hFaceBrush) _GDIPlus_PenDispose($hSecPen) _GDIPlus_PenDispose($hMinPen) _GDIPlus_PenDispose($hHourPen) _GDIPlus_PenDispose($hBlackPen) _GDIPlus_BitmapDispose($hClockBitmap) _GDIPlus_GraphicsDispose($hClockGraphic) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>Clock Func WM_NCMBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam $iChSize = $iStartSz EndFunc ;==>WM_NCMBUTTONDOWN Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Local $iWheelDist, $iRate $iRate = 0.25 $iWheelDist = BitShift($wParam, 16) $iChSize -= Int($iRate * $iWheelDist) If $iChSize < 120 Then $iChSize = 120 If $iChSize > $iCanvasSz - (2 * $iMargin) Then $iChSize = $iCanvasSz - (2 * $iMargin) EndFunc ;==>WM_MOUSEWHEEL Func WM_NCHITTEST($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Return $HTCAPTION EndFunc ;==>WM_NCHITTEST  
  17. Like
    user4157124 reacted to EmilyLove in [UDF] Rollbar Error Reporting v0.2   
    What is Rollbar?
    Rollbar provides real-time error alerting & debugging tools for developers. Learn more about it at https://rollbar.com/product/
    Demo: https://rollbar.com/demo/demo/
    Screenshot:
    Instructions: (RollbarTest.au3)
    ; Include RollbarSDK #include "RollbarSDK.au3" ;Turns on ConsoleWrite debugging override. ;Global $Rollbar_Debug=False ; Initialize RollbarSDK with the project's API key. ; Parameters ....: $__Rollbar_sToken - [Required] Go to https://rollbar.com/<User>/<ProjectName>/settings/access_tokens/ for your project. Use the token for post_server_item. _Rollbar_Init("eaa8464a4082eeabd9454465b8f0c0af") ; Write code that causes an error you want to catch, then call ; _Rollbar_Send ; Parameters ....: $__Rollbar_sErrorLevel - [Required] Must be one of the following values: Debug, Info, Warning, Error, Critical. ; $__Rollbar_sMessage - [Required] The message to be sent. This should contain any useful debugging info that will help you debug. ; $__Rollbar_sMessageSummary - [Optional] A string that will be used as the title of the Item occurrences will be grouped into. Max length 255 characters. If omitted, Rollbar will determine this on the backend. _Rollbar_Send("Debug", "This is an debug message. If you received this, you were successful!", "Debug Message") _Rollbar_Send("Info", "This is a test message. If you received this, you were successful!", "Info Message") _Rollbar_Send("Warning", "This is an warning message. If you received this, you were successful!", "Warning Message") _Rollbar_Send("Error", "This is an error message. If you received this, you were successful!", "Error Message") _Rollbar_Send("Critical", "This is an critical message. If you received this, you were successful!", "Critical Message") _Rollbar_Send("Info", "This is a test message. If you received this, you were successful!") ;No Message ; Rollbar_Send's helper functions ; Parameters ....: $__Rollbar_sMessage - [Required] The message to be sent. This should contain any useful debugging info that will help you debug. ; $__Rollbar_sMessageSummary - [Optional] A string that will be used as the title of the Item occurrences will be grouped into. Max length 255 characters. If omitted, Rollbar will determine this on the backend. _Rollbar_SendDebug("This is an debug message. If you received this, you were successful!", "Debug Message") _Rollbar_SendInfo("This is a test message. If you received this, you were successful!", "Info Message") _Rollbar_SendWarning("This is an warning message. If you received this, you were successful!", "Warning Message") _Rollbar_SendError("This is an error message. If you received this, you were successful!", "Error Message") _Rollbar_SendCritical("This is an critical message. If you received this, you were successful!", "Critical Message") ; Usable Example Local $sImportantFile = "C:\NOTAREALFILE_1234554321.txt" Switch FileExists($sImportantFile) Case True MsgBox(0, "Example Script", "An important file was found. Continuing...") Case Else _Rollbar_SendCritical('An important file was missing. Halting... File: "' & $sImportantFile & '"', 'Important file "' & $sImportantFile & '" is missing.') EndSwitch Notes: Please comment your feedback, advice, & suggestions below. While this is only a proof of concept, I will expand its feature set for everyone to use. 
    Right now, it is fully functional but not tested in production.
     
     
    Changelog:
    RollbarSDK.au3
    RollbarTest.au3
    v0.2
     
    v0.1.1
     
  18. Like
    user4157124 reacted to caramen in AutoIt Snippets   
    To know if a control is checked or not. 
    Func _IsChecked($idControlID)     Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc  
  19. Like
    user4157124 reacted to Sidley in GDI+ Gauges   
    Hello folks, I've been working on a couple of GDI+ gauges, they need a bit of polish here and there I'd appreciate it if you guys/girls could play around and give me some suggestions. Cheers.
     
    #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=Gauges With Sliders.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstants.au3> #include <GDIplus.au3> #include <ColorConstants.au3> #include <Array.au3> Global Const $width = @DesktopWidth * 3 / 4 Global Const $height = @DesktopHeight Global $title = "GDI+" ; Build your GUI here Opt("GUIOnEventMode", 1) Global $hwnd = GUICreate($title, @DesktopWidth, @DesktopHeight, -1, -1, $WS_SIZEBOX) GUISetOnEvent($GUI_EVENT_CLOSE, "close") GUISetState() #Region Sliders Global $VariableMaxValue = 100 Global $SecondaryMaxValue = 100 Global $VariableMinValue = 0 Global $HexLabel = GUICtrlCreateLabel("Hex Value: ", @DesktopWidth - 300, 50, 150, 20) GUICtrlSetColor($HexLabel, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $idSliderThick = GUICtrlCreateSlider(@DesktopWidth - 300, 100, 250, 20) GUICtrlSetLimit(-1, 240, 0) ; change min/max value GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $ThickLabel = GUICtrlCreateLabel("Thickness Value: " & GUICtrlRead($idSliderThick), @DesktopWidth - 300, 120, 150, 20) GUICtrlSetColor($ThickLabel, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $idSliderVal = GUICtrlCreateSlider(@DesktopWidth - 300, 150, 250, 20) GUICtrlSetLimit(-1, $VariableMaxValue, $VariableMinValue) ; change min/max value GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $ValLabel = GUICtrlCreateLabel("Variable Value: " & GUICtrlRead($idSliderVal), @DesktopWidth - 300, 170, 150, 20) GUICtrlSetColor($ValLabel, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $idSliderScale = GUICtrlCreateSlider(@DesktopWidth - 300, 200, 250, 20) GUICtrlSetLimit(-1, 20, 0) ; change min/max value GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $ScaleLabel = GUICtrlCreateLabel("Scale Value: " & (GUICtrlRead($idSliderScale) * .1), @DesktopWidth - 300, 220, 150, 20) GUICtrlSetColor($ScaleLabel, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $idStartAngleScale = GUICtrlCreateSlider(@DesktopWidth - 300, 250, 250, 20) GUICtrlSetLimit(-1, 360, 0) ; change min/max value GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $StartAngleLabel = GUICtrlCreateLabel("Angle Value: " & GUICtrlRead($idStartAngleScale), @DesktopWidth - 300, 270, 150, 20) GUICtrlSetColor($StartAngleLabel, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $idSweepScale = GUICtrlCreateSlider(@DesktopWidth - 300, 300, 250, 20) GUICtrlSetLimit(-1, 360, 0) ; change min/max value GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $SweepLabel = GUICtrlCreateLabel("Sweep Value: " & GUICtrlRead($idSweepScale), @DesktopWidth - 300, 320, 150, 20) GUICtrlSetColor($SweepLabel, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $idCheckmarksScale = GUICtrlCreateSlider(@DesktopWidth - 300, 350, 250, 20) GUICtrlSetLimit(-1, 20, 0) ; change min/max value GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $CheckmarkLabel = GUICtrlCreateLabel("No. of Checkmarks: " & GUICtrlRead($idCheckmarksScale), @DesktopWidth - 300, 370, 150, 20) GUICtrlSetColor($CheckmarkLabel, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $idVarMin = GUICtrlCreateSlider(@DesktopWidth - 300, 450, 250, 20) GUICtrlSetLimit(-1, 0, -50) ; change min/max value GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $MinLabel = GUICtrlCreateLabel("Min Value: " & GUICtrlRead($idVarMin), @DesktopWidth - 300, 470, 150, 20) GUICtrlSetColor($MinLabel, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $RadioGroup1 = GUICtrlCreateGroup("", @DesktopWidth - 300, 500, 200, 50) Global $clockwiseCtrl = GUICtrlCreateRadio("Clockwise", @DesktopWidth - 280, 520, 80, 20) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlSetColor(-1, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $antiClockwiseCtrl = GUICtrlCreateRadio("Anti-clockwise", @DesktopWidth - 200, 520, 85, 20) GUICtrlSetColor(-1, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $RadioGroup2 = GUICtrlCreateGroup("", @DesktopWidth - 300, 550, 200, 50) Global $RadialCtrl = GUICtrlCreateRadio("Radial", @DesktopWidth - 280, 570, 80, 20) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlSetColor(-1, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) Global $SquareCtrl = GUICtrlCreateRadio("Linear", @DesktopWidth - 200, 570, 85, 20) GUICtrlSetColor(-1, $COLOR_WHITE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKVCENTER) GUICtrlSetData($idSliderThick, 35) GUICtrlSetData($idSliderScale, 10) GUICtrlSetData($idStartAngleScale, 180) GUICtrlSetData($idSweepScale, 180) GUICtrlSetData($idCheckmarksScale, 10) #EndRegion Sliders GUISetBkColor(0x303030) Global $aWindowSize = WinGetClientSize($hwnd) ; Load your GDI+ resources here: _GDIPlus_Startup() Global $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd) Global $bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics) Global $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap) While 1 _GDIPlus_GraphicsClear($backbuffer, 0xFF303030) Sleep(50) #Region Test Variables Global $Thickness = GUICtrlRead($idSliderThick) Global $Variable = GUICtrlRead($idSliderVal) Global $tValue = 0xFF000000 Global $rValue = 0x00FF0000 Global $gValue = BitShift((255 - (($Variable / $VariableMaxValue) * 255)), -8) Global $bValue = 0x00 Global $ScalingFactor = GUICtrlRead($idSliderScale) / 10 GUICtrlSetData($HexLabel, "Hex Value: " & HEX(BitOR($tValue, $rValue, $gValue, $bValue))) Global $PenColour = ("0x" & HEX(BitOR($tValue, $rValue, $gValue, $bValue))) GUICtrlSetData($ValLabel, "Variable Value: " & GUICtrlRead($idSliderVal)) GUICtrlSetData($ThickLabel, "Thickness Value: " & GUICtrlRead($idSliderThick)) GUICtrlSetData($ScaleLabel, "Scale Value: " & (GUICtrlRead($idSliderScale) * .1)) GUICtrlSetData($StartAngleLabel, "Angle Value: " & GUICtrlRead($idStartAngleScale)) GUICtrlSetData($SweepLabel, "Sweep Value: " & GUICtrlRead($idSweepScale)) GUICtrlSetData($CheckmarkLabel, "No. Of Checkmarks: " & GUICtrlRead($idCheckmarksScale)) GUICtrlSetData($MinLabel, "Min Value: " & GUICtrlRead($idVarMin)) GUICtrlSetLimit($idSliderVal, $VariableMaxValue, $VariableMinValue) Local $Radius = 300 If GUICtrlRead($clockwiseCtrl) = $GUI_CHECKED Then Local $Clockwise = True Else Local $Clockwise = False EndIf Local $StartAngle = GUICtrlRead($idStartAngleScale) Local $SweepAngle = GUICtrlRead($idSweepScale) Local $CentrePointX = 500 Local $CentrePointY = 500 Local $NoOfCheckmarks = GUICtrlRead($idCheckmarksScale) Local $CheckLength = 15 Local $AllowedLimit = 75 Local $VariableLimit = True Local $VariableMinValue = GUICtrlRead($idVarMin) #EndRegion Test Variables #Region Function Call If GUICtrlRead($RadialCtrl) = $GUI_CHECKED Then _GDIPlus_GraphicsDrawPath($backbuffer, _Gauges_DrawRadialGauge($backbuffer, $CentrePointX, $CentrePointY, $Radius, $Thickness, $Variable, $ScalingFactor, $Clockwise, $StartAngle, $SweepAngle, $VariableMaxValue, $NoOfCheckmarks, $CheckLength, $VariableLimit, $AllowedLimit, $VariableMinValue)) GUICtrlSetState($idSliderThick, $GUI_SHOW) GUICtrlSetState($ThickLabel, $GUI_SHOW) GUICtrlSetState($idStartAngleScale, $GUI_SHOW) GUICtrlSetState($StartAngleLabel, $GUI_SHOW) GUICtrlSetState($idSweepScale, $GUI_SHOW) GUICtrlSetState($SweepLabel, $GUI_SHOW) GUICtrlSetState($RadioGroup1, $GUI_SHOW) GUICtrlSetState($clockwiseCtrl, $GUI_SHOW) GUICtrlSetState($antiClockwiseCtrl, $GUI_SHOW) Else _GDIPlus_GraphicsDrawPath($backbuffer, _Gauges_DrawLinearGauge($backbuffer, $CentrePointX, $CentrePointY, 600, 100, $Variable, $ScalingFactor, $NoOfCheckmarks, $CheckLength, $VariableMaxValue, $VariableLimit, $AllowedLimit, $VariableMinValue)) GUICtrlSetState($idSliderThick, $GUI_HIDE) GUICtrlSetState($ThickLabel, $GUI_HIDE) GUICtrlSetState($idStartAngleScale, $GUI_HIDE) GUICtrlSetState($StartAngleLabel, $GUI_HIDE) GUICtrlSetState($idSweepScale, $GUI_HIDE) GUICtrlSetState($SweepLabel, $GUI_HIDE) GUICtrlSetState($RadioGroup1, $GUI_HIDE) GUICtrlSetState($clockwiseCtrl, $GUI_HIDE) GUICtrlSetState($antiClockwiseCtrl, $GUI_HIDE) EndIf #EndRegion Function Call _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height) WEnd Func close() _GDIPlus_GraphicsDispose($backbuffer) _GDIPlus_BitmapDispose($bitmap) _GDIPlus_GraphicsDispose($graphics) _GDIPlus_Shutdown() Exit EndFunc ;==>close #Region Functions #Region Draw Linear Gauge ; #FUNCTION# ==================================================================================================================== ; Name...........: _Gauges_DrawLinearGauge ; Description ...: Creates a horizontal or vertical gauge in the graphics backbuffer ; Syntax.........: _Gauges_DrawLinearGauge(ByRef $backbuffer, $CentrePointX, $CentrePointY, $GaugeWidth, $GaugeHeight, $Variable, [$ScalingFactor = 1, [$NoOfCheckmarks = 6, [$CheckLength = 20, ; + [$VariableMaxValue = 256, [$VariableLimit = False, [$AllowedLimit = 0, [$VariableMinValue = 0]]]]]]] ) ; Parameters ....: $backbuffer - [byref] The graphics object to draw the gauge to. ; $CentrePointX - The horizontal coordinate of the centre of the gauge. ; $CentrePointY - The vertical coordinate of the centre of the gauge. ; $GaugeWidth - The width of the gauge (Duh). ; $GaugeHeight - The height of the gauge. ; $Variable - The variable used to change the gauge. ; $ScalingFactor - [optional] Scales the gauge by this factor. Default is 1, i.e. no scaling. ; $NoOfCheckmarks - [optional] The number of dashes indicating a scale around the gauge. Default is 6. ; $CheckLength - [optional] The length of the checkmarks in pixels. Default is 20. ; $VariableMaxValue - [optional] The maximum value of the variable. Default is 256. ; $VariableLimit - [optional] Boolean, if TRUE, displays a red limit indicator on the scale. Default is FALSE. ; $AllowedLimit -[optional] The value of the above limit if it is drawn. Default is 0. ; $VariableMinValue -[optional] The minimum value of the variable. Only used if negative numbers are required. Default is 0. ; Author ........: Simon Renardson (Sidley) ; Modified.......: ; Remarks .......: There is a more comprehensive function available, but I deemed it overkill for the majority of people. ; Related .......: _GDIPlus_ ; Example .......: Yes ; =============================================================================================================================== ;Draw a Linear gauge to the screen Func _Gauges_DrawLinearGauge(ByRef $backbuffer, $CentrePointX, $CentrePointY, $GaugeWidth, $GaugeHeight, $Variable, $ScalingFactor = 1, $NoOfCheckmarks = 6, $CheckLength = 20, $VariableMaxValue = 256, $VariableLimit = False, $AllowedLimit = 0, $VariableMinValue = 0) If $Variable >= 0 Then Local $BrushColour = ("0xFF4BF221") Else Local $BrushColour = ("0xFFFF0000") EndIf If $GaugeWidth >= $GaugeHeight Then Local $GaugeBrush = _GDIPlus_HatchBrushCreate(1, 0x00000000, $BrushColour) ;Set to vertical hatch if the gauge is horizontal Else Local $GaugeBrush = _GDIPlus_HatchBrushCreate(0, 0x00000000, $BrushColour) ;Set to horizontal hatch if the gauge is vertical EndIf Local $TextBrush = _GDIPlus_BrushCreateSolid($BrushColour) Local $Path = _GDIPlus_PathCreate() Local $hPen = _GDIPlus_PenCreate("0xFF96A29F", 2 * $ScalingFactor) ; Off-white pen for outlines Local $AllowedPen = _GDIPlus_PenCreate("0xFFFF0000", 8 * $ScalingFactor) ;Red pen for allowed speed indicators If $GaugeWidth >= $GaugeHeight Then ;If the gauge is to be length wise _GDIPlus_PathAddLine($Path, $CentrePointX - ((($GaugeWidth / 2) + $VariableMinValue * ($GaugeWidth / ($VariableMaxValue - $VariableMinValue))) * $ScalingFactor), ($CentrePointY + ($GaugeHeight / 2) * $ScalingFactor), $CentrePointX - ((($GaugeWidth / 2) + $VariableMinValue * ($GaugeWidth / ($VariableMaxValue - $VariableMinValue))) * $ScalingFactor) + ($Variable * ($GaugeWidth / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor), ($CentrePointY + ($GaugeHeight / 2) * $ScalingFactor)) _GDIPlus_PathAddLine($Path, $CentrePointX - ((($GaugeWidth / 2) + $VariableMinValue * ($GaugeWidth / ($VariableMaxValue - $VariableMinValue))) * $ScalingFactor) + ($Variable * ($GaugeWidth / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor), ($CentrePointY - ($GaugeHeight / 2) * $ScalingFactor), $CentrePointX - ((($GaugeWidth / 2) + $VariableMinValue * ($GaugeWidth / ($VariableMaxValue - $VariableMinValue))) * $ScalingFactor), ($CentrePointY - ($GaugeHeight / 2) * $ScalingFactor)) _GDIPlus_PathCloseFigure($Path) Else ;If the gauge is to be height wise _GDIPlus_PathAddLine($Path, ($CentrePointX + ($GaugeWidth / 2) * $ScalingFactor), ($CentrePointY + (($GaugeHeight / 2) * $ScalingFactor)) + ($VariableMinValue * ($GaugeHeight / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor), ($CentrePointX + ($GaugeWidth / 2) * $ScalingFactor), ($CentrePointY + (($GaugeHeight / 2) * $ScalingFactor)) + ($VariableMinValue * ($GaugeHeight / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor) - $Variable * ($GaugeHeight / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor) _GDIPlus_PathAddLine($Path, ($CentrePointX - ($GaugeWidth / 2) * $ScalingFactor), ($CentrePointY + (($GaugeHeight / 2) * $ScalingFactor)) + ($VariableMinValue * ($GaugeHeight / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor) - $Variable * ($GaugeHeight / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor, ($CentrePointX - ($GaugeWidth / 2) * $ScalingFactor), ($CentrePointY + (($GaugeHeight / 2) * $ScalingFactor)) + ($VariableMinValue * ($GaugeHeight / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor)) _GDIPlus_PathCloseFigure($Path) EndIf _GDIPlus_GraphicsFillPath($backbuffer, $Path, $GaugeBrush) ;Draw the gauge _DrawBar($backbuffer, $CentrePointX, $CentrePointY, $GaugeWidth, $GaugeHeight, $VariableMaxValue, $VariableMinValue, $hPen, $ScalingFactor) ;Draw the outline for the gauge _DrawLinearGaugeCheckMarks($backbuffer, $CentrePointX, $CentrePointY, $GaugeWidth, $GaugeHeight, $ScalingFactor, $VariableMaxValue, $NoOfCheckmarks, $CheckLength, $hPen) ;Draw the checkmarks for the gauge If $VariableLimit Then _DrawLinearAllowedSpeed($backbuffer, $CentrePointX, $CentrePointY, $GaugeWidth, $GaugeHeight, $VariableMaxValue, $AllowedLimit, $AllowedPen, $ScalingFactor, $VariableLimit) ;Draw the allowed speed indicator(s) for the gauge EndIf _LinearGaugeText($backbuffer, $Variable, $CentrePointX, $CentrePointY, $GaugeWidth, $GaugeHeight, $ScalingFactor, $TextBrush) ;Put the gauge text above the gauge _GDIPlus_PathDispose($Path) ;Tidy up _GDIPlus_BrushDispose($GaugeBrush) _GDIPlus_PenDispose($hPen) _GDIPlus_PenDispose($AllowedPen) _GDIPlus_BrushDispose($TextBrush) EndFunc ;==>_DrawLinearGauge ;Draw the text for the main gauge Func _LinearGaugeText(ByRef $backbuffer, $Variable, $CentrePointX, $CentrePointY, $GaugeWidth, $GaugeHeight, $ScalingFactor, ByRef $TextBrush) Local $FontSize = 80 * $ScalingFactor ;Linear gauge font size Local $Path = _GDIPlus_PathCreate() Local $Format = _GDIPlus_StringFormatCreate() Local $Family = _GDIPlus_FontFamilyCreate("Agency FB") ;Centre text font Local $Font = _GDIPlus_FontCreate($Family, $FontSize, 2) _GDIPlus_StringFormatSetAlign($Format, 2) ;Right align _GDIPlus_GraphicsSetSmoothingMode($backbuffer, 2) ;Change smoothing mode for text If $GaugeWidth >= $GaugeHeight Then Local $Layout = _GDIPlus_RectFCreate($CentrePointX - ($FontSize * $ScalingFactor / 2), $CentrePointY - ($GaugeHeight / 2 * $ScalingFactor) - $FontSize * 1.5 * $ScalingFactor) ;Set text position for inner text Else Local $Layout = _GDIPlus_RectFCreate($CentrePointX - ($GaugeWidth / 2) * $ScalingFactor - $FontSize * 2, ($CentrePointY - $FontSize * $ScalingFactor / 2)) ;Set text positionfor inner text EndIf _GDIPlus_PathAddString($Path, $Variable, $Layout, $Family, 0, $FontSize * $ScalingFactor) _GDIPlus_GraphicsFillPath($backbuffer, $Path, $TextBrush) $Layout = 0 _GDIPlus_PathDispose($Path) _GDIPlus_FontDispose($Font) _GDIPlus_StringFormatDispose($Format) _GDIPlus_FontFamilyDispose($Family) EndFunc ;==>_LinearGaugeText ;Draw the outline of the gauge Func _DrawBar(ByRef $backbuffer, $CentrePointX, $CentrePointY, $GaugeWidth, $GaugeHeight, $VariableMaxValue, $VariableMinValue, ByRef $hPen, $ScalingFactor = 1) Local $Path = _GDIPlus_PathCreate() _GDIPlus_PathAddLine($Path, $CentrePointX - ($GaugeWidth / 2) * $ScalingFactor, $CentrePointY - ($GaugeHeight / 2) * $ScalingFactor, $CentrePointX + ($GaugeWidth / 2) * $ScalingFactor, $CentrePointY - ($GaugeHeight / 2) * $ScalingFactor) _GDIPlus_PathAddLine($Path, $CentrePointX + ($GaugeWidth / 2) * $ScalingFactor, $CentrePointY + ($GaugeHeight / 2) * $ScalingFactor, $CentrePointX - ($GaugeWidth / 2) * $ScalingFactor, $CentrePointY + ($GaugeHeight / 2) * $ScalingFactor) _GDIPlus_PathCloseFigure($Path) If $GaugeWidth >= $GaugeHeight Then _GDIPlus_GraphicsDrawLine($backbuffer, $CentrePointX - ($GaugeWidth / 2 * $ScalingFactor) - $VariableMinValue * ($GaugeWidth / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor, $CentrePointY - ($GaugeHeight / 2) * $ScalingFactor, $CentrePointX - ($GaugeWidth / 2 * $ScalingFactor) - $VariableMinValue * ($GaugeWidth / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor, $CentrePointY + ($GaugeHeight / 2) * $ScalingFactor, $hPen) Else _GDIPlus_GraphicsDrawLine($backbuffer, $CentrePointX - ($GaugeWidth / 2 * $ScalingFactor), ($CentrePointY + (($GaugeHeight / 2) * $ScalingFactor)) + ($VariableMinValue * ($GaugeHeight / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor), $CentrePointX + ($GaugeWidth / 2 * $ScalingFactor), ($CentrePointY + (($GaugeHeight / 2) * $ScalingFactor)) + ($VariableMinValue * ($GaugeHeight / ($VariableMaxValue - $VariableMinValue)) * $ScalingFactor), $hPen) EndIf _GDIPlus_GraphicsDrawPath($backbuffer, $Path, $hPen) ;Draw the outline _GDIPlus_PathDispose($Path) EndFunc ;==>_DrawBar ;Draw the checkmarks Func _DrawLinearGaugeCheckMarks(ByRef $backbuffer, $CentrePointX, $CentrePointY, $GaugeWidth, $GaugeHeight, $ScalingFactor, $VariableMaxValue, $NoOfCheckmarks, $CheckLength, ByRef $hPen) Local $TextBrush = _GDIPlus_BrushCreateSolid("0xFFFFFFFF") ;Solid white brush for the checkmarks Local $aPoints[$NoOfCheckmarks][2] ;Two cartesian coordinates for each checkmark Local $aMarkText[$NoOfCheckmarks] ; The text for each checkmark ;Create the font for the checkmarks Local $FontSize = 15 * $ScalingFactor ;The font size (Scaled) Local $Format = _GDIPlus_StringFormatCreate() Local $Family = _GDIPlus_FontFamilyCreate("Agency FB") Local $Font = _GDIPlus_FontCreate($Family, $FontSize, 2) For $i = 0 to($NoOfCheckmarks - 1) $aMarkText[$i] = Round($VariableMinValue + (($VariableMaxValue - $VariableMinValue) / ($NoOfCheckmarks - 1)) * $i) Next If $GaugeWidth >= $GaugeHeight Then _GDIPlus_GraphicsDrawLine($backbuffer, $CentrePointX - ($GaugeWidth / 2) * $ScalingFactor, $CentrePointY - ($GaugeHeight / 2 + 10) * $ScalingFactor, $CentrePointX + ($GaugeWidth / 2) * $ScalingFactor, $CentrePointY - ($GaugeHeight / 2 + 10) * $ScalingFactor, $hPen) For $i = 0 to($NoOfCheckmarks - 1) ;Set the coordinates of each checkmark $aPoints[$i][0] = ($CentrePointX - ($GaugeWidth / 2) * $ScalingFactor) + ($GaugeWidth * $ScalingFactor / ($NoOfCheckmarks - 1)) * $i ;Set x position depending on the number of checkmarks and the length of the gauge $aPoints[$i][1] = $CentrePointY - ($GaugeHeight / 2 + 10) * $ScalingFactor ;Height remains uniform Next For $i = 0 to($NoOfCheckmarks - 1) _GDIPlus_GraphicsDrawLine($backbuffer, $aPoints[$i][0], $aPoints[$i][1], $aPoints[$i][0], ($aPoints[$i][1] - $CheckLength * $ScalingFactor), $hPen) ;Draw a line $Checklength long $Layout = _GDIPlus_RectFCreate(($aPoints[$i][0] - $FontSize), ($aPoints[$i][1] - $CheckLength * $ScalingFactor - ($FontSize * 1.5) * $ScalingFactor), 0, 0) _GDIPlus_GraphicsDrawStringEx($backbuffer, $aMarkText[$i], $Font, $Layout, $Format, $TextBrush) ;Draw the sext for the checkmark Next Else _GDIPlus_GraphicsDrawLine($backbuffer, $CentrePointX - ($GaugeWidth / 2 * $ScalingFactor) - 10 * $ScalingFactor, $CentrePointY + ($GaugeHeight / 2) * $ScalingFactor, $CentrePointX - ($GaugeWidth / 2 * $ScalingFactor) - 10 * $ScalingFactor, $CentrePointY - ($GaugeHeight / 2) * $ScalingFactor, $hPen) For $i = 0 to($NoOfCheckmarks - 1) $aPoints[$i][0] = $CentrePointX - ($GaugeWidth / 2 + 10) * $ScalingFactor $aPoints[$i][1] = ($CentrePointY + ($GaugeHeight / 2) * $ScalingFactor) - ($GaugeHeight * $ScalingFactor / ($NoOfCheckmarks - 1)) * $i Next For $i = 0 to($NoOfCheckmarks - 1) _GDIPlus_GraphicsDrawLine($backbuffer, $aPoints[$i][0], $aPoints[$i][1], $aPoints[$i][0] - $CheckLength * $ScalingFactor, $aPoints[$i][1], $hPen) $Layout = _GDIPlus_RectFCreate(($aPoints[$i][0] - $CheckLength * $ScalingFactor - $FontSize * 2.5), $aPoints[$i][1] - $FontSize / 1.5, 0, 0) _GDIPlus_GraphicsDrawStringEx($backbuffer, $aMarkText[$i], $Font, $Layout, $Format, $TextBrush) Next EndIf $Layout = 0 _GDIPlus_BrushDispose($TextBrush) _GDIPlus_FontDispose($Font) _GDIPlus_StringFormatDispose($Format) _GDIPlus_FontFamilyDispose($Family) EndFunc ;==>_DrawLinearGaugeCheckMarks Func _DrawLinearAllowedSpeed(ByRef $backbuffer, $CentrePointX, $CentrePointY, $GaugeWidth, $GaugeHeight, $MaxValue, $AllowedLimit, ByRef $AllowedPen, $ScalingFactor, $PrimaryAllowedSpeed) Local $Path = _GDIPlus_PathCreate() If $PrimaryAllowedSpeed Then If $GaugeWidth >= $GaugeHeight Then _GDIPlus_PathAddLine($Path, $CentrePointX - ($GaugeWidth / 2) * $ScalingFactor, $CentrePointY - ($GaugeHeight / 2 + 15) * $ScalingFactor + 3 * $ScalingFactor, ($CentrePointX - (($GaugeWidth / 2) * $ScalingFactor)) + ($GaugeWidth * $AllowedLimit / 100 * $ScalingFactor), $CentrePointY - ($GaugeHeight / 2 + 15) * $ScalingFactor + 3 * $ScalingFactor) Else _GDIPlus_PathAddLine($Path, $CentrePointX - ($GaugeWidth / 2) * $ScalingFactor - 10 * $ScalingFactor, $CentrePointY + ($GaugeHeight / 2) * $ScalingFactor, $CentrePointX - ($GaugeWidth / 2) * $ScalingFactor - 10 * $ScalingFactor, ($CentrePointY + ($GaugeHeight / 2) * $ScalingFactor) - ($GaugeHeight * $AllowedLimit / 100 * $ScalingFactor)) EndIf EndIf _GDIPlus_GraphicsDrawPath($backbuffer, $Path, $AllowedPen) _GDIPlus_PathDispose($Path) EndFunc ;==>_DrawLinearAllowedSpeed #EndRegion Draw Linear Gauge #Region Draw Radial Gauge ; #FUNCTION# ==================================================================================================================== ; Name...........: _Gauges_DrawRadialGauge ; Description ...: Creates a radial gauge in the graphics backbuffer ; Syntax.........: _Gauges_DrawRadialGauge(ByRef $backbuffer, $CentrePointX, $CentrePointY, $Radius, $Thickness, $Variable, $ScalingFactor = 1, $Clockwise = True, $StartAngle = 0, ; + $SweepAngle = 180, $NoOfCheckmarks = 6, $CheckLength = 20, $VariableMaxValue = 256, $VariableLimit = True, $AllowedLimit = 0, $VariableMinValue = 0) ; Parameters ....: $backbuffer - [byref] The graphics object to draw the gauge to. ; $CentrePointX - The horizontal coordinate of the centre of the gauge. ; $CentrePointY - The vertical coordinate of the centre of the gauge. ; $Radius - The radius of the outer edge of the gauge. ; $Thickness - The thickness of the gauge in pixels. ; $Variable - The variable used to change the gauge. ; $ScalingFactor - [optional] Scales the gauge by this factor. Default is 1, i.e. no scaling. ; $Clockwise - [optional] Boolean, determines whether the gauge fills clockwise or anti-clockwise. Default is TRUE, i.e. clockwise. ; $StartAngle - [optional] The starting angle of the gauge. Default is 0 (East). ; $SweepAngle - [optional] The sweep angle of the gauge (How many degrees it rotates through). The default is 180. ; $NoOfCheckmarks - [optional] The number of dashes indicating a scale around the gauge. Default is 6. ; $CheckLength - [optional] The length of the checkmarks in pixels. Default is 20. ; $VariableMaxValue - [optional] The maximum value of the variable. Default is 256. ; $VariableLimit - [optional] Boolean, if TRUE, displays a red limit indicator on the scale. Default is FALSE. ; $AllowedLimit -[optional] The value of the above limit if it is drawn. Default is 0. ; $VariableMinValue -[optional] The minimum value of the variable. Only used if negative numbers are required. Default is 0. ; Author ........: Simon Renardson (Sidley) ; Modified.......: ; Remarks .......: There is a more comprehensive function available, but I deemed it overkill for the majority of people. ; Related .......: _GDIPlus_ ; Example .......: Yes ; =============================================================================================================================== ;Draw Gauge (Speed/Load Level) ;Creates Completed Radial Gauge ;~ _DrawRadialGauge($CentrePointX, $CentrePointY, $Radius, $Thickness, $Variable, [$ScalingFactor = 1, [$Clockwise = True, [$StartAngle = 0, [$SweepAngle = 180, [$MaxValue = 256, [$NoOfCheckmarks = 10, [$CheckLength = 20]]]]]]]) Func _Gauges_DrawRadialGauge(ByRef $backbuffer, $CentrePointX, $CentrePointY, $Radius, $Thickness, $Variable, $ScalingFactor = 1, $Clockwise = True, $StartAngle = 0, $SweepAngle = 180, $NoOfCheckmarks = 6, $CheckLength = 20, $VariableMaxValue = 256, $VariableLimit = True, $AllowedLimit = 0, $VariableMinValue = 0) Local $BrushColour = ("0x" & HEX(BitOR(0xFFFF0000, BitShift((255 - (($Variable / $VariableMaxValue) * 255)), -8)))) Local $GaugeBrush = _GDIPlus_HatchBrushCreate(39, 0xFF000000, $BrushColour) Local $TextBrush = _GDIPlus_BrushCreateSolid($BrushColour) Local $Path = _GDIPlus_PathCreate() Local $hPen = _GDIPlus_PenCreate("0xFF96A29F", 2 * $ScalingFactor) ;Pen colour Local $AllowedPen = _GDIPlus_PenCreate("0xFFFF0000", 10 * $ScalingFactor) _GDIPlus_GraphicsSetSmoothingMode($backbuffer, 2) ;TODO may need to be removed If $Clockwise Then ;If clockwise rotation _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), $StartAngle - $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue)), $Variable * $SweepAngle / ($VariableMaxValue - $VariableMinValue)) ;Add outer arc of gauge $Radius -= ($Thickness * $ScalingFactor) ;Reduce radius for inner arc by the thickness of the gauge _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), $StartAngle - $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue)) + ($Variable * $SweepAngle / ($VariableMaxValue - $VariableMinValue)), (-1 * $Variable * $SweepAngle / ($VariableMaxValue - $VariableMinValue))) ;Add inner arc of Gauge Else ;If anti-clockwise rotation _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), $StartAngle + $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue)), (-1 * $Variable * $SweepAngle / ($VariableMaxValue - $VariableMinValue))) ;Add outer arc of gauge $Radius -= ($Thickness * $ScalingFactor) ;Reduce radius for inner arcby the thickness of the gauge _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), $StartAngle + $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue)) - ($Variable * $SweepAngle / ($VariableMaxValue - $VariableMinValue)), $Variable * $SweepAngle / ($VariableMaxValue - $VariableMinValue)) ;Add inner arc of Gauge EndIf $Radius += ($Thickness * $ScalingFactor) ;Return radius to original size _GDIPlus_PathCloseFigure($Path) ;Close the two arcs _GDIPlus_GraphicsFillPath($backbuffer, $Path, $GaugeBrush) ;Fill the gauge and centre text with colour _DrawRadialGaugeText($backbuffer, $Variable, $CentrePointX, $CentrePointY, $Clockwise, $Radius, $ScalingFactor, $TextBrush) ;Draw the centre text _DrawGaugeOutline($backbuffer, $CentrePointX, $CentrePointY, $Radius, $VariableMaxValue, $VariableMinValue, $Thickness, $ScalingFactor, $Clockwise, $StartAngle, $SweepAngle, $hPen) ;Draw the gauge outline _DrawIndicators($backbuffer, $CentrePointX, $CentrePointY, $Radius, $Thickness, $Clockwise, $ScalingFactor, $StartAngle, $SweepAngle, $hPen, True) ;Draw scale arc _DrawCheckMarks($backbuffer, $CentrePointX, $CentrePointY, $Radius, $Thickness, $ScalingFactor, $VariableMaxValue, $NoOfCheckmarks, $CheckLength, $StartAngle, $SweepAngle, $hPen, True) ;Draw scale checkmarks If $VariableLimit Then _DrawRadialAllowedSpeed($backbuffer, $CentrePointX, $CentrePointY, $Radius, $Thickness, $Clockwise, $ScalingFactor, $StartAngle, $SweepAngle, $AllowedLimit, $AllowedPen, True) ;Draw allowed speed limits EndIf _GDIPlus_PathDispose($Path) ;Tidy up _GDIPlus_BrushDispose($GaugeBrush) _GDIPlus_BrushDispose($TextBrush) _GDIPlus_PenDispose($hPen) _GDIPlus_PenDispose($AllowedPen) EndFunc ;==>_DrawRadialGauge ;Draw Variable Value (Text, Load/Speed Value) ;Creates The Centre Text of the Radial Gauge ;~ Func _DrawRadialGaugeText($ValueText, $CentrePointX, $CentrePointY, $Clockwise, $Radius, $ScalingFactor) Func _DrawRadialGaugeText(ByRef $backbuffer, $ValueText, $CentrePointX, $CentrePointY, $Clockwise, $Radius, $ScalingFactor, ByRef $TextBrush) Local $FontSize = 180 * $ScalingFactor ;Default font size (Scaled) Local $Text = _GDIPlus_PathCreate() Local $Format = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($Format, 2) ;Align right (Doesn't seem to make a difference) Local $Family = _GDIPlus_FontFamilyCreate("Agency FB") ;Centre text font Local $Font = _GDIPlus_FontCreate($Family, $FontSize, 2) Local $Layout = _GDIPlus_RectFCreate($CentrePointX - ($FontSize / 1.3) * $ScalingFactor, $CentrePointY - $FontSize * $ScalingFactor / 2) ;Set position (Top left) _GDIPlus_PathAddString($Text, Round($ValueText, 1), $Layout, $Family, 0, $FontSize * $ScalingFactor) ;Add value to path (To 1 decimal place) _GDIPlus_GraphicsFillPath($backbuffer, $Text, $TextBrush) $Layout = 0 ;Tidy up _GDIPlus_PathDispose($Text) _GDIPlus_FontDispose($Font) _GDIPlus_StringFormatDispose($Format) _GDIPlus_FontFamilyDispose($Family) EndFunc ;==>_DrawRadialGaugeText ;Draw Gauge Outline ;Creates the Outline of the Radial Gauge ;~ Func _DrawGaugeOutline($CentrePointX, $CentrePointY, $Radius, $Thickness, $ScalingFactor, $Clockwise, $StartAngle, $SweepAngle) Func _DrawGaugeOutline(ByRef $backbuffer, $CentrePointX, $CentrePointY, $Radius, $VariableMaxValue, $VariableMinValue, $Thickness, $ScalingFactor, $Clockwise, $StartAngle, $SweepAngle, ByRef $hPen) Local $Path = _GDIPlus_PathCreate() Local Const $PI = 3.141592653589793 $Radius += 2 ;Put the outline 2 px outside the gauge If $Clockwise Then ;If the gauge is to be filled clockwise _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), $StartAngle, $SweepAngle) _GDIPlus_GraphicsDrawLine($backbuffer, $CentrePointX + ($Radius * $ScalingFactor * Cos(($PI / 180) * ($StartAngle - $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue))))), $CentrePointY + ($Radius * $ScalingFactor * Sin(($PI / 180) * ($StartAngle - $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue))))), $CentrePointX + (($Radius - ($Thickness * $ScalingFactor) - (4 * $ScalingFactor)) * Cos(($PI / 180) * ($StartAngle - $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue)))) * $ScalingFactor), $CentrePointY + (($Radius - ($Thickness * $ScalingFactor) - 4) * $ScalingFactor * Sin(($PI / 180) * ($StartAngle - $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue))))), $hPen) $Radius -= ($Thickness * $ScalingFactor) ;Reduce radius for inner arc $Radius -= 4 _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), ($StartAngle + $SweepAngle), -$SweepAngle) Else _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), $StartAngle, -$SweepAngle) _GDIPlus_GraphicsDrawLine($backbuffer, $CentrePointX + ($Radius * $ScalingFactor * Cos(($PI / 180) * ($StartAngle + $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue))))), $CentrePointY + ($Radius * $ScalingFactor * Sin(($PI / 180) * ($StartAngle + $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue))))), $CentrePointX + (($Radius - ($Thickness * $ScalingFactor) - (4 * $ScalingFactor)) * Cos(($PI / 180) * ($StartAngle + $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue)))) * $ScalingFactor), $CentrePointY + (($Radius - ($Thickness * $ScalingFactor) - 4) * $ScalingFactor * Sin(($PI / 180) * ($StartAngle + $VariableMinValue * ($SweepAngle / ($VariableMaxValue - $VariableMinValue))))), $hPen) $Radius -= ($Thickness * $ScalingFactor) ;Reduce radius for inner arc $Radius -= 4 _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), $StartAngle - $SweepAngle, $SweepAngle) EndIf _GDIPlus_PathCloseFigure($Path) ;Close the path _GDIPlus_GraphicsDrawPath($backbuffer, $Path, $hPen) ;Draw the path _GDIPlus_PathDispose($Path) EndFunc ;==>_DrawGaugeOutline ;Draw Scale(s) ;Creates a number of indicative markings around the centre of the radial gauge ;~ Func _DrawIndicators($CentrePointX, $CentrePointY, $Radius, $Thickness, $Clockwise, $ScalingFactor, $StartAngle, $SweepAngle) Func _DrawIndicators(ByRef $backbuffer, $CentrePointX, $CentrePointY, $Radius, $Thickness, $Clockwise, $ScalingFactor, $StartAngle, $SweepAngle, ByRef $hPen, $Inside) Local $Path = _GDIPlus_PathCreate() $Radius -= ($Thickness + 20) * $ScalingFactor If $Clockwise Then _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), $StartAngle, $SweepAngle) Else ;Doesn't make much difference, but it will be 180 degrees out _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), $StartAngle, -$SweepAngle) EndIf _GDIPlus_GraphicsDrawPath($backbuffer, $Path, $hPen) _GDIPlus_PathDispose($Path) EndFunc ;==>_DrawIndicators ;Draw the allowed speed marker Func _DrawRadialAllowedSpeed(ByRef $backbuffer, $CentrePointX, $CentrePointY, $Radius, $Thickness, $Clockwise, $ScalingFactor, $StartAngle, $SweepAngle, _ $AllowedLimit, ByRef $AllowedPen, $Inside) Local $Path = _GDIPlus_PathCreate() $Radius -= ($Thickness + 24) * $ScalingFactor If $Clockwise Then ;Display in a clockwise direction _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), $StartAngle, $SweepAngle * $AllowedLimit / 100) ElseIf NOT $Clockwise Then ;Display in an anti-clockwise direction _GDIPlus_PathAddArc($Path, ($CentrePointX - ($Radius * $ScalingFactor)), ($CentrePointY - ($Radius * $ScalingFactor)), ($Radius * $ScalingFactor * 2), ($Radius * $ScalingFactor * 2), $StartAngle, -$SweepAngle * $AllowedLimit / 100) EndIf _GDIPlus_GraphicsDrawPath($backbuffer, $Path, $AllowedPen) ;Draw with the red pen ($AllowedPen) _GDIPlus_PathDispose($Path) EndFunc ;==>_DrawRadialAllowedSpeed ;DrawCheckmarks (Checkmarks) ;Creates the checkmarks and text around the indicator gauge ;~ Func _DrawCheckMarks($CentrePointX, $CentrePointY, $Radius, $Thickness, $ScalingFactor, $MaxValue, $NoOfCheckmarks, $CheckLength, $StartAngle, $SweepAngle, $hPen) Func _DrawCheckMarks(ByRef $backbuffer, $CentrePointX, $CentrePointY, $Radius, $Thickness, $ScalingFactor, $VariableMaxValue, $NoOfCheckmarks, $CheckLength, $StartAngle, _ $SweepAngle, ByRef $hPen, $Inside) Local Const $PI = 3.141592653589793 Local $TextBrush = _GDIPlus_BrushCreateSolid("0xFFFFFFFF") Local $aPoints[$NoOfCheckmarks][4] ;Creates an array of four points for each check line Local $aMarkText[$NoOfCheckmarks] ;Creates the text for the checkmarks $Radius -= ($Thickness + 20) * $ScalingFactor For $i = 0 to ($NoOfCheckmarks-1) $aMarkText[$i] = Round((($VariableMaxValue - $VariableMinValue) / ($NoOfCheckmarks - 1)) * $i) + $VariableMinValue ;Round checkmark values to one decimal place Next Local $aAngles[$NoOfCheckmarks] = [] ;Create an array to hold the angles at which the checkmarks should be If $Clockwise Then For $i = 0 to($NoOfCheckmarks - 1) $aAngles[$i] = $StartAngle + (($SweepAngle / ($NoOfCheckmarks - 1)) * $i) ;Spread out checkmarks evenly over the gauge Next Else ;For anticlockwise filling gauge For $i = 0 to($NoOfCheckmarks - 1) $aAngles[$i] = $StartAngle - (($SweepAngle / ($NoOfCheckmarks - 1)) * $i) ;Spread out checkmarks evenly over the gauge Next EndIf For $i = 0 to($NoOfCheckmarks - 1) $aAngles[$i] = $aAngles[$i] * $PI / 180 ;Convert degrees to radians $aPoints[$i][0] = $CentrePointX + ($Radius * Cos($aAngles[$i]) * $ScalingFactor) ;Create cartesian coordinates for the check lines from polar coordinates (Radius, angle) $aPoints[$i][1] = $CentrePointY + ($Radius * Sin($aAngles[$i]) * $ScalingFactor) $aPoints[$i][2] = $CentrePointX + (($Radius - ($CheckLength * $ScalingFactor)) * Cos($aAngles[$i]) * $ScalingFactor) $aPoints[$i][3] = $CentrePointY + (($Radius - ($CheckLength * $ScalingFactor)) * Sin($aAngles[$i]) * $ScalingFactor) Next ;Font data for checkmark text Local $Format = _GDIPlus_StringFormatCreate() Local $Family = _GDIPlus_FontFamilyCreate("Agency FB") Local $FontSize = 15 Local $Font = _GDIPlus_FontCreate($Family, $FontSize * $ScalingFactor, 2) For $i = 0 to($NoOfCheckmarks - 1) ;For each checkmark _GDIPlus_GraphicsDrawLine($backbuffer, $aPoints[$i][0], $aPoints[$i][1], $aPoints[$i][2], $aPoints[$i][3], $hPen) ;Draw the lines $Layout = _GDIPlus_RectFCreate($aPoints[$i][2] - ($FontSize * Cos($aAngles[$i])) - (18 * $ScalingFactor), $aPoints[$i][3] - ($FontSize * Sin($aAngles[$i]) + 10), 0, 0) _GDIPlus_GraphicsDrawStringEx($backbuffer, $aMarkText[$i], $Font, $Layout, $Format, $TextBrush) Next $Layout = 0 _GDIPlus_BrushDispose($TextBrush) _GDIPlus_FontDispose($Font) _GDIPlus_StringFormatDispose($Format) _GDIPlus_FontFamilyDispose($Family) EndFunc ;==>_DrawCheckMarks #EndRegion Draw Radial Gauge #EndRegion Functions  
  20. Like
    user4157124 got a reaction from Xandy in TCPStartUp() in a UDF - best practice?   
    For a UDF, TCPStartUp() is the including script's responsibility (like caling _GDIPlus_Startup() or _SQLite_Startup() prior to using functions from a UDF that depend on these libraries). Check in each function helps debugging (uninitialized use will error eventually, a check at least identifies the cause), but TCP functions return @error WSANOTINITIALISED (10093) if called prior to TCPStartup() already.

    Generally speaking, anything of global effect is the script's (not UDF's) responsibility (code becomes inflexible/unmanageable otherwise). Of course you can do as you please (it's a convenience vs. flexibility trade off eventually).
  21. Like
    user4157124 reacted to Funtime60 in Execute from var?   
    @JohnOne I have good news for you! execute() already supports multi-line commands! it simply need to know where carriage-return line-feeds need to go by replacing carriage-return line-feeds with the autoit syntax for such. A simple stringreplace($string,@CRLF,' @CRLF ') applied to an .au3 makes it executable using execute().
    Here is a proof of concept converter that converts an .au3 to something that can be run using an execute()
    Local $filepath = FileOpenDialog("Open File",@ScriptDir,"AutoIt Source (*.au3)|Plain Text (*.txt)|All Files (*.*)") Local $filehand = FileOpen($filepath) Local $filedata = FileRead($filehand) MsgBox(0,"Init",$filedata) Local $savedata = StringReplace($filedata,@CRLF,' @CRLF ') MsgBox(0,"Done",$savedata) Local $savepath = FileSaveDialog("Save File",@ScriptDir,"Plain Text (*.txt)|All Files (*.*)") Local $savehand = FileOpen($savepath,2) FileWrite($savehand,$savedata) Apologies if I said something previously mentioned, I missed that this thread was two pages. I hope my post is still relevant.
  22. Like
    user4157124 reacted to jchd in Stack Overflow Documentation   
    I strongly disagree. The full AutoIt documentation is already inline (and offline with all AutoIt installations). Having to maintain another doc format is just duplication of efforts with no benefit I can foresee.
  23. Like
    user4157124 reacted to Subz in Arranging XML File from one line into separate line   
    Have a look at XML.au3 by @mLipok, the function XML_Tidy does what you want, however I tried with your xml file but I can't parse the file, I couldn't parse it with XML Notepad either, I tried adding the namespace but it said it's invalid.
    Unfortunately I've got to get some shuteye, work in three hours   But maybe you or some else can figure out the correct schema, if not I'll look at it again after work.
     
  24. Thanks
    user4157124 got a reaction from orbs in what's it called when you have \n instead of @CRLF?   
    Possibly just:

    ConsoleWrite(StringFormat('\r\n@CRLF before this\t@TAB before this\n'))

    Called escape sequence.
  25. Like
    user4157124 reacted to jchd in Invisible red dot UNICODE character   
    With a bit broader range of removal:
    StringRegExpReplace('F‌inal', '[\x{200B}-\x{200D}]', '') Yet removing ZWJ (U+0200D) may change semantic of Unicode flux in some languages.
    You may also discover other such special codepoints, depending on the nature of the input text.
×
×
  • Create New...