Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/15/2020 in all areas

  1. The tool takes a "snapshot" of your system. Then you scroll through the pages of information like a book. Its broken down into sections heaps, modules, threads and processes. The only limitation is it only has the same rights as the user so if you're running as a base level user you're not going to get as much info as a person running as admin. Also you can only obtain information about the modules loaded into the memory of the calling process. This is pretty standard across all calls for module information. As you can clearly see from the example a user needs to use the CreateToolhelp32Snapshot_onit at the beginning of their code. It builds all the structs and sets the size of the struct to the first value of the structure. Then call xxxx32first() to initiatialize the group then every subsequent call is made to xxxx32next(). The displays are exactly that displays to demonstrate its working. How you harvest and use the information is up to you. The sample is just a sample the main functions that make it work live in the 32Snapshot.AU3 that is attached. Last but not least what makes this useful vs the built in calls for processlist(), _winapi_Enummodule() etc is that this returns more information. Instead of just the name and pid of a process it returns information about the base address, parent processes, how many threads all types of stuff. UPDATE v1.0 There were issues i just found with the modules part of the script. Should be fixed now Update: Its all fixed up seems to be operating correctly let me know otherwise. If you are using any of the 32W functions let me know how theyr working. I couldn't test those. But ever edit that was made to their counterpart were made to the 32W UPDATE Edit edit there was a logic issue in the newly posted sample script $bool[0][0] will never be false if its an array. needs to be $bool[0][1]<>0 Its fixed in the latest sample as of the time i press this button. UPDATE!!!!!!!!!!!!!!!!!!! wasnt able to get information on the processes and I was wondering if autoit.exe was set to run as admin even tho the script was set to require admin.... the fact that the autoit.exe was not set to run as admin i wasn't getting all the info. . New file uploaded. Should be perfect this time . This is my wrapper on the Toolhelp32snapshot functions available on the kernel32.dll. I'm super stoked on it. Probably the best thing I've ever written. Looking for some testers. I'd also like to note if you're not getting the expected results it is possible that it's a bug in the script it is also possible that you have virus protection running or not running scite as admin or some other privileges issue. That's about as far as I can go on that subject. https://docs.microsoft.com/en-us/windows/win32/api/tlhelp32/ ;~ ============================================================================================================================================================================================================================= ;~ Title Description Author:$MarkyRocks!! ;~ ========================================================================================================================================================================================================================================== ;~ CreateToolhelp32Snapshot($Flags,$ProcessID ) Takes a snapshot of the specified processes, as well as the heaps, modules, and threads used by these processes. ;~ ======================================================================================================================================================================================================================================== ;~ Heap32First($hSnapShot) Retrieves information about the first block of a heap that has been allocated by a process. ;~ ================================================================================================================================================================================================================================================ ;~ ===================================================================================================================================================================================================================================================== ;~ Heap32Next($hSnapShot) Retrieves information about the next block of a heap that has been allocated by a process. ;~ ================================================================================================================================================================================================================================================== ;~ Module32First($hSnapShot) Retrieves information about the first module associated with a process. ;~ ======================================================================================================================================================================================================================================================== ;~ Module32FirstW($hSnapShot) Retrieves information about the first module associated with a process. ;~ ================================================================================================================================================================================================================================================== ;~ Module32Next($hSnapShot) Retrieves information about the next module associated with a process or thread. ;~ ================================================================================================================================================================================================================================================== ;~ Module32NextW($hSnapShot) Retrieves information about the next module associated with a process or thread. ;~ ================================================================================================================================================================================================================================================== ;~ Process32First($hSnapShot) Retrieves information about the first process encountered in a system snapshot. ;~ ================================================================================================================================================================================================================================================== ;~ Process32FirstW($hSnapShot) Retrieves information about the first process encountered in a system snapshot. ;~ ================================================================================================================================================================================================================================================== ;~ Process32Next($hSnapShot) Retrieves information about the next process recorded in a system snapshot. ;~ ================================================================================================================================================================================================================================================== ;~ Process32NextW($hSnapShot) Retrieves information about the next process recorded in a system snapshot. ;~ ================================================================================================================================================================================================================================================== ;~ Thread32First($hSnapShot) Retrieves information about the first thread of any process encountered in a system snapshot. ;~ ================================================================================================================================================================================================================================================== ;~ Thread32Next($hSnapShot) Retrieves information about the next thread of any process encountered in the system memory snapshot. ;~ ================================================================================================================================================================================================================================================== ;~ Toolhelp32ReadProcessMemory($th32ProcessID,$lpBaseAddress,$lpBuffer,$cbRead,$lpNumberOfBytesRead) Copies memory allocated to another process into an application-supplied buffer. ;~ ================================================================================================================================================================================================================================================== ;~ CreateToolHelp32Snapshot_OnInit() Builds the structs gets things ready !!!!!!!!!!Must Be Ran on Start of your code ;~ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;~ CreateToolHelp32Snapshot_OnExit() Release Memory resources SHOULD Be automatic but it can't hurt to run it anyways ;===================================================================================================================================================================================================================================================== ;~ CreateToolhelp32Snapshot($flags,$iPID) Takes a snapshot of the specified processes, as well as the heaps, modules, and threads used by these processes. ;~ ;~ Returns a Handle to the Snapshot of the system or Exit on fail Markyrocks ;~====================================================================================================================================================================================================================================================== just a sample of how it works. The include is attached for download 32Snapshot.au3
    1 point
  2. For the record the API used in _WINAPI_PathRemoveBackslash, PathRemoveBackslashW, has been deprecated. PathCchRemoveBackslash or PathCchRemoveBackslashEx, should be used in place of PathRemoveBackslashW to prevent the possibility of a buffer overrun.
    1 point
  3. There is a typo in that line : $oExcel.Activesheet.Range('A'& $vTopCount & ':G' & $vTopCount).Interior.ColorIndex = 50
    1 point
  4. Why go through the hassle of dealing with a behemoth like Symantec, or any other AV company for that matter, over scripts that you create? I could understand it if it were a full-blown application, but these are scripts. If it were me, and I had control over my environment (as any IT department or professional should), I would designate a folder structure that scripts can be run from, apply the appropriate ACLs to that structure, and exclude that folder structure from AV scanning. That way, you don't have to play whack-a-mole with AV companies and you can rest assured that your scripts wont be quarantined due to any AV-related issues.
    1 point
  5. I suppose showing them this thread could help : https://www.autoitscript.com/forum/topic/34658-are-my-autoit-exes-really-infected/ cause it did helped me in the past ps. it is not specific to Symantec, as far as I know all AVs react the same...
    1 point
  6. Rei10, You seem incapable of understanding that when we say we will not help you bypass CAPTCHAs we mean it. Practically every one of your threads has tried to gain information on this matter and despite several Moderator posts closing threads you continue to do so. Thus is your final warning - one more thread from you dealing with anything that even remotely resembles your previous attempts at CAPTCHA bypass will result in your removal from the community. Your choice - obey the Forum rules or leave, voluntarily or involuntarily. Thread locked. M23 P.S. And before you ask, no-one "holds" me either.
    1 point
  7. Here is how to do line by line, although you could actually just use RangeRead to read "A:F" and just paste the entire column in the second workbook. #include <Array.au3> #include <Excel.au3> #include <ExcelConstants.au3> #include <MsgBoxConstants.au3> ;########################################################################################################################### $csvFile1 = "C:\temp\testFile1.csv" $csvFile2 = "C:\temp\testFile2.csv" Const $sType = $xlCSVMSDOS ;Set the type as CSV ;########################################################################################################################### Local $oExcel = _Excel_Open() ; Create application object and create a new workbook Local $oWorkbook1 = _Excel_BookOpen($oExcel, $csvFile1) ;Open TEST File1 Local $oWorkbook2 = _Excel_BookOpen($oExcel, $csvFile2) ;Open TEST File2 ;########################################################################################################################### Local $oRange, $oTotalRow = $oWorkbook1.ActiveSheet.UsedRange.Rows.Count ;########################################################################################################################### For $i = 1 To $oTotalRow Step +1 $oRange = _Excel_RangeRead($oWorkbook1, Default, "A" & $i & ":" & "F" & $i) _Excel_RangeWrite($oWorkbook2, Default, $oRange, "A" & $i) Next _Excel_BookSaveAs($oWorkbook2, $oWorkbook2, $xlCSVMSDOS) ;########################################################################################################################### $oWorkbook1.Close $oWorkbook2.Close ;########################################################################################################################### _Excel_Close($oExcel) ;###########################################################################################################################
    1 point
  8. Ok I figured I would post and update. I went through everything with a fine tooth comb. The _Thread32 funcs there was a math problem in there that was causing the data to not make sense. I was having issues with the struct sizes not being correct to hold the data, I had issues with all kinds of stuff. All Fixed up. Theres error handling in there now. When it gets to the end of a group of pages a msg displays saying that its at the end and the loop exits. I even added in some extra checks to the sample code. The ony other thing I can add is I was getting an error message about the functionsW but i assume thats bc im running on 32 autoit and i believe theyre 64 bit functions. I Updated the sample code and the new much better working .au3 has been uploaded. But in conclusion IT WORKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1 point
  9. No need to be sorry, we all miss things... Speaking of, have you seen my sanity?
    1 point
  10. ok so the first suggestion that i have for you is try simplifying your existing code until you get the desired behavior and then build up from there. My second suggestion is that you should familiarize yourself with like gui msgs and how they work bc this doesn't seem that different. you are using a message to pass a picture like a variable into a function. Think of messages like an event. like you have a loop that supposed to count to 10 once it gets to 10 it sends up a flag like "hey i counted to 10". The point of this message is to trigger the next series of events. that in mind you have messages being sent from the main while loop that are not being triggered by any particular event. how or why or when they're being sent is completely up to time delays and happenstance. So the idea is in the main something happened it sends a message to a sub thread to do something bc of a previous event etc. again you have sent and received msg values going into parameters for a function. that function is startin b4 the message is received so whatever the default value of AuThread_GetMsg() is being passed (Probably Null) to the imagesearch function and probably resulting in a error or causing other unpredictable behavior. the way the msgs are in the example it seems like they're just Boolean. like if a msg was received msg=true. if a msg was not received then its false. but with boolean 0 or null is false anything else is considered true. edit. you could probably use the received msg as a parameter for a function but you need to add a conditional statement like if $msg then pixelsearch ect endif obviously to ensure that the value is being set b4 it executes the function call. Using the msg to pass a variable seems unnecessary bc the whole point of the function is to find that picture. that being said you could probably use it like that to clean up your code and have less functions.
    1 point
  11. Sidley

    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
    1 point
  12. Hmmm, thinking about this, wouldn't it even be better not to clear the edit, but use the difference in size ($fs_new - $fs) to performa a FileSetPos() operation instead to move the read pointer to the new content and then do a FileReadLine() loop for new lines only? But I'm not quite sure if FileReadLine() works correctly in conjunction with FileSetPos() . Edit: The FileOpen() handle prevented me to write to the log via notepad... I'm not quite sure if this wouldn't be true for other programs too, thus I think it's better to close the handle once the data has been received. Of course this works only if new data is only appended to the log. ;Coded by UEZ Build 2010-06-30, tweaked by KaFu ;-) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiEdit.au3> Opt("GUIOnEventMode", 1) Global $iMemo, $new_line $width = 1024 $height = 600 $hGUI = GUICreate("Realtime Log Reader by UEZ 2010", $width, $height, -1, -1, Default, $WS_EX_TOPMOST) $iMemo = GUICtrlCreateEdit("", 0, 0, $width, $height, $ES_AUTOVSCROLL + $WS_VSCROLL + $WS_HSCROLL + $ES_READONLY) GUICtrlSetLimit(-1, 0x7FFFFFFF) GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") GUISetState() If $CmdLine[0] > 0 And FileExists($CmdLine[1]) Then $file = $CmdLine[1] Else ;$file = @WindowsDir & "\WindowsUpdate.log" $file = @ScriptDir & "\test.log" EndIf $hFile = FileOpen($file) $txt = FileRead($hFile) GUICtrlSetData($iMemo, $txt, 1) _GUICtrlEdit_LineScroll($iMemo, 1, 0xfffffff) FileClose($hFile) $fs = FileGetSize($file) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") While Sleep(1000) $fs_new = FileGetSize($file) If $fs < $fs_new Then $hFile = FileOpen($file,128) ConsoleWrite($fs_new - $fs & @crlf) FileSetPos($hFile, -($fs_new - $fs), 2) $new_line = FileRead($hFile) FileClose($hFile) GUICtrlSetData($iMemo, $new_line, 1) $fs = $fs_new EndIf WEnd Func _Exit() GUIDelete($hGUI) Exit EndFunc ;==>_Exit
    1 point
×
×
  • Create New...