Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/25/2019 in all areas

  1. RTFC, It is a chimera - in this specific case the badge of one of my previous units. M23
    3 points
  2. Truly, I feel blessed today, as for once in my life I was faster than the black double goose-tailed winged dragon-griffon beasty lying in a bowl of red chilli (or whatever it is).
    2 points
  3. LAST VERSION - 1.1 18-May-12 Control Viewer (CV) is a replacement of AutoIt Window Info with a number of advantages. I tried to stick to the interface of the last, so you almost do not have to be retrained. During testing, I never managed to find any controls that could not be identified by CV (on the contrary, shows a lot of hidden controls, especially for the system windows). The all program settings are stored in the following registry key: HKEY_CURRENT_USERSoftwareY'sControl Viewer The main differences CV from AWI Shows the complete list of all existing controls for the window that are interested (visible, hidden and deleted controls are displayed with different colors that can be changed to any other).Dynamically changing information during search for the windows and their controls.Ability to quickly switch between controls in the list.Ability to show/hide any controls from the list (useful for the overlaping controls).Information for the Style and ExStyle parameters shown in the form of hexadecimal values​​, and as its flags.Added the PID and Path parameters in the Window tab and ability to quickly open a folder that containing the process file.Added the coordinate system relative to the selected control.Shows a color of the selected pixel in RGB and BGR formats.Shows an example fill of the selected color.Ability to select the text encoding (affects the Text parameter in the Control tab).The complete change the appearance of pop-up frame for the selected controls.Simple and convenient tool to get a screenshot of the part screen of interest for publication on the forum (Capture tab).Create a report in the clipboard or a text file for subsequent publication on the forum.Search all running AutoIt scripts and their windows in the system (AutoIt tab).User-friendly interface. Used shortcuts Ctrl+Alt+T - Enable/Disable "Always On Top" mode (also available from the menu). Ctrl+Alt+H - Enable/Disable highlight selected controls (also available from the menu). Ctrl+A - Select all text (works in any input field). Ctrl - Hold down when moving the mouse to scroll the screenshot (Capture tab). Shift - Hold down when stretching/compression of the contour frame for an equilateral resizing screenshots (Capture tab). DoubleClick (on the screenshot) - Save the image to a file (Capture tab). DoubleClick (on any list item) - Open a folder with the file of the process or AutoIt script (AutoIt tab). Del (on any list item) - Close process (AutoIt tab). F5 - Updating the list (AutoIt tab). If anyone have any questions or comments about CV, please post it in this thread. I will be glad to any feedback and suggestions. Files to download Binary (x86 and x64) Redirection to CV_bin.zip, 1.14 MB CV_bin.html Source Redirection to CV_source.zip, 691 KB CV_source.html
    1 point
  4. Sidley

    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
    1 point
  5. If you get it from an input, maybe you can force a trailing backslash. "something.csv\" is a folder
    1 point
  6. jchd

    String Manipulation(scrool)

    Try this and adapt: HotKeySet("{ESC}", _Terminate) Local $title = "Adelitas Way - What It Takes" & " here more long text, much larger than LCD 24-char display (example) ... " Local $max = 24 Local $str = $title & $title ; yes, concat two copies of text Local $i While 1 $i += 1 ConsoleWrite(StringMid($str, Mod($i, StringLen($title)), $max) & @CRLF) Sleep(200) WEnd Func _Terminate() Exit EndFunc
    1 point
  7. Did you look at the examples in that thread? How do you think you'll get paid for a script, if you can't even bother looking at examples given to you? Who would pay for a script from a coder who can't even figure out how to use something handed to him on a silver platter?
    1 point
  8. Get all texts in a Chrome document This example shows how to extract all texts in a Chrome document. The previous webpage (page 2) is used as an example. Don't forget this: To be able to spy on web content in Google Chrome it's necessary to enable accessibility by entering chrome://accessibility/ in the address bar of a new tab item, and then check the five check boxes that are located in a column in upper left corner down along the left edge. Then the accessibility tab can be closed again. It's a global setting that applies to all open and new tabs until Chrome is closed. Without accessibility enabled you are only able to investigate the outer elements of Chrome but not web content. SampleCode1.au3 shows how to find the first text (SampleCode1-a.au3 is the code generated directly by UIASpy): #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;#AutoIt3Wrapper_UseX64=n ; If target application is running as 32 bit code ;#AutoIt3Wrapper_UseX64=y ; If target application is running as 64 bit code #include "UIA_Constants.au3" ; Can be copied from UIASpy Includes folder ;#include "UIA_Functions.au3" ; Can be copied from UIASpy Includes folder ;#include "UIA_SafeArray.au3" ; Can be copied from UIASpy Includes folder ;#include "UIA_Variant.au3" ; Can be copied from UIASpy Includes folder Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtag_IUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Get Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement( $pDesktop ) $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF ) ConsoleWrite( "$oDesktop OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition0 $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "Chrome_WidgetWin_1", $pCondition0 ) If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF ) ConsoleWrite( "$pCondition0 OK" & @CRLF ) Local $pPane1, $oPane1 $oDesktop.FindFirst( $TreeScope_Descendants, $pCondition0, $pPane1 ) $oPane1 = ObjCreateInterface( $pPane1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oPane1 ) Then Return ConsoleWrite( "$oPane1 ERR" & @CRLF ) ConsoleWrite( "$oPane1 OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition1 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_TextControlTypeId, $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) Local $pText1, $oText1 $oPane1.FindFirst( $TreeScope_Descendants, $pCondition1, $pText1 ) $oText1 = ObjCreateInterface( $pText1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oText1 ) Then Return ConsoleWrite( "$oText1 ERR" & @CRLF ) ConsoleWrite( "$oText1 OK" & @CRLF ) EndFunc SciTE output: $oUIAutomation OK $oDesktop OK --- Find window/control --- $pCondition0 OK $oPane1 OK --- Find window/control --- $pCondition1 OK $oText1 OK SampleCode2.au3 shows how to find all texts (SampleCode2-a.au3 is the code generated directly by UIASpy): #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;#AutoIt3Wrapper_UseX64=n ; If target application is running as 32 bit code ;#AutoIt3Wrapper_UseX64=y ; If target application is running as 64 bit code #include "UIA_Constants.au3" ; Can be copied from UIASpy Includes folder ;#include "UIA_Functions.au3" ; Can be copied from UIASpy Includes folder ;#include "UIA_SafeArray.au3" ; Can be copied from UIASpy Includes folder ;#include "UIA_Variant.au3" ; Can be copied from UIASpy Includes folder Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtag_IUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Get Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement( $pDesktop ) $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF ) ConsoleWrite( "$oDesktop OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition0 $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "Chrome_WidgetWin_1", $pCondition0 ) If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF ) ConsoleWrite( "$pCondition0 OK" & @CRLF ) Local $pPane1, $oPane1 $oDesktop.FindFirst( $TreeScope_Descendants, $pCondition0, $pPane1 ) $oPane1 = ObjCreateInterface( $pPane1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oPane1 ) Then Return ConsoleWrite( "$oPane1 ERR" & @CRLF ) ConsoleWrite( "$oPane1 OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition1 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_TextControlTypeId, $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) #cs Local $pText1, $oText1 $oPane1.FindFirst( $TreeScope_Descendants, $pCondition1, $pText1 ) $oText1 = ObjCreateInterface( $pText1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oText1 ) Then Return ConsoleWrite( "$oText1 ERR" & @CRLF ) ConsoleWrite( "$oText1 OK" & @CRLF ) #ce Local $pElements $oPane1.FindAll( $TreeScope_Descendants, $pCondition1, $pElements ) ; --- Code Snippets --- ConsoleWrite( "--- Code Snippets ---" & @CRLF ) Local $oUIElementArray1, $iLength1 ; $pElements is a pointer to an UI Automation element array $oUIElementArray1 = ObjCreateInterFace( $pElements, $sIID_IUIAutomationElementArray, $dtag_IUIAutomationElementArray ) $oUIElementArray1.Length( $iLength1 ) If Not $iLength1 Then Return ConsoleWrite( "$iLength1 = 0 ERR" & @CRLF ) ConsoleWrite( "$iLength1 = " & $iLength1 & @CRLF ) ; --- Code Snippets --- ConsoleWrite( "--- Code Snippets ---" & @CRLF ) Local $pElement1, $oElement1, $sValue1 For $i = 0 To $iLength1 - 1 $oUIElementArray1.GetElement( $i, $pElement1 ) $oElement1 = ObjCreateInterface( $pElement1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) $oElement1.GetCurrentPropertyValue( $UIA_NamePropertyId, $sValue1 ) ConsoleWrite( "$sValue1 = " & $sValue1 & @CRLF ) Next EndFunc SampleCode2.au3 is a continuation of SampleCode1.au3 where FindFirst is replaced with FindAll and code snippets are added to Create an UI Automation element array from pointer Traverse an array to get access to individual elements The code snippets are added ín two steps in UIASpy. It's only possible to use item 2 if item 1 is completed. Item 2 is simply not shown in the listview unless item 1 is completed. SciTE output (in part, see SampleCode2.txt): $oUIAutomation OK $oDesktop OK --- Find window/control --- $pCondition0 OK $oPane1 OK --- Find window/control --- $pCondition1 OK --- Code Snippets --- $iLength1 = 3768 --- Code Snippets --- $sValue1 = Existing user? Sign In   $sValue1 = ? $sValue1 = Sign Up $sValue1 = Browse $sValue1 = Forums $sValue1 = Downloads $sValue1 = Calendar $sValue1 = Forum Rules $sValue1 = Wiki $sValue1 = AutoIt Resources $sValue1 = ? $sValue1 = FAQ $sValue1 = Our Picks $sValue1 = ? $sValue1 = $sValue1 = All Activity $sValue1 = ? $sValue1 = Home $sValue1 = ? $sValue1 = AutoIt v3 Search for SEKOMD in SampleCode2.txt to see all activity of this user. Why is the URL in the address bar not included in the texts? Because the address bar is part of the outer elements of the Chrome window and therefore not included in the web document itself. AllChromeTexts.7z
    1 point
  9. Melba23

    HotKeySet Issue

    seadoggie0, HotKeySet can only work on one key, possibly with one or more of the Shft/Ctrl/Alt/Windows modifier keys. The {ALT} keyword is used to define the Alt key itself - so your first attempt will not work as you are trying to use 2 keys - one of which cannot be used as it is one of the modifiers (as explained in the Help file). Your second attempt is syntactically correct and so will work as expected. M23
    1 point
  10. @Marga FYI, I don't believe just copying / pasting the code will solve the issue. I believe this is a timing issue, where perhaps the website is refreshed in the background and the IE object get invalidated. If we can replicate the issue on demand, then it should be possible to update the UDF to fix the problem. Edit: I also found the following information -- https://www.autoitscript.com/forum/topic/174191-ieau3-_ietablegetcollection-repeated-execution-issue/?_fromLogin=1 https://www.autoitscript.com/trac/autoit/ticket/3097
    1 point
  11. Now its my turn to give back to the community ( Better late than never :P).. First i want to thank progAndy for his amazing UDF which this idea came from And the AutoitObject Team (For making autoit fun again) I dont have so much to say more thant to let the project speak for itself, ive had this for a couple of months but it was "integrated" into my own "framework" but today I decided to release it because i have seen some people on the forum search for something like this. What libraries does this use and are they included? Connector/C 6.1.6 ( https://dev.mysql.com/downloads/connector/c/ ) And yes, they are included in the download so nothing has to be installed or anything What are the features: Prepared statements 32 and 64 bit environment Multiline prepared statements Simplicity User-friendly PDO-like Syntax & Methods (http://php.net/pdo) So whats the difference between this and x's Mysql UDF? When you are fetching your data from your database, you use your table-names to display them, like this: with $MySql Local $Vars = ["?", $lastname, "?", $age] .prepare("SELECT id, surname, lastname FROM users WHERE lastname = ? AND AGE > ?") .execute($Vars) Consolewrite(stringformat("Searchresult: %d Hits", .rowCount()) for $row in $oRows consolewrite("Surname: " & $row.surname & @crlf) consolewrite("Lastname: " & $row.lastname & @crlf) next endwith Function-list (Yeah i might improve this when i have time) ; Every parameter is a default value of method _miniSQL_setDllDir(@ScriptDir); returns nothing Local Const $MySql = _miniSQL_LoadLibrary(); Returns object with methods ; Starts the library, connects to the database and returns the object $MySql.Startup($sHost, $sUser, $sPass = "", $sDatabase = "", $iPort = 0, $sUnix_socket = "", $iClient_Flag = 0); Returns TRUE if connection was succeded otherwise FALSE ; Shuts down the library and prevents any methods to be executed $MySql.Shutdown() ; The desired SQL query goes here (SELECT x FROM table) $MySql.prepare($sQuery); Returns nothing ; Used for multi-line prepared statements (See Example3 - newline prepared statements) $MySql.PrepareGlue($sQuery); Returns nothing ; Cleans any previous prepared statement of any kind $MySql.PrepareClean(); Returns nothing ; Executes a prepared statement of any kind, with or without passed arguments $MySql.execute($aVars = Null, $iExecuteStyle = $_miniSQL_ExecuteStoreResult); returns TRUE if success, otherwise FALSE ; Options for $iExecuteStyle: $_miniSQL_ExecuteStoreResult = 0 and $_miniSQL_ExecuteOnly = 1 ; Fetches previous executed prepared statement (If anything was stored "see Options for iExecuteStyle") $MySql.fetchAll($iFetchStyle = $_miniSQL_FetchObject); Returns (Depends on $iFetchStyle) ; Options for $iFetchStyle: $_miniSQL_FetchObject = 0 (Default), $_miniSQL_FetchSingleObject = 1, $_miniSQL_FetchArray = 2, $_miniSQL_FetchSingleValue = 3 ; Gives you the "lastinsertId" (The last id that was affected) $MySql.lastInsertId(); Returns the last affected id ; Counts the affected rows done by any MySQL operation (INSERT\SELECT\UPDATE\DELETE) $MySql.rowCount(); Returns how affected rows ; Use this if want to know why nothing is working (Can be used anywhere after $MySql.Startup()) $MySql.debug(); Returns nothing ; Retrives the last MysqlError set $MySql.SQLerror(); Returns error (If any) Here is some example code: #include <miniSQL\miniSQL.au3> ; Set default dir for our dlls (Only has to be done once) _miniSQL_setDllDir(@ScriptDir & "\miniSQL") ; Declared as CONST since we never want to accidentally change the variables original value Local Const $MySql = _miniSQL_LoadLibrary() ;Connect to database & Init library If Not $MySql.Startup("localhost", "user", "pass", "db", 3306) Then MsgBox(0, "Failed to start library", $MySql.debug()) Exit EndIf With $MySql .prepare("SELECT * FROM members") If Not .execute() Then MsgBox(0, "Failed to execute query", .sqlError()) Local $oRows = .fetchAll() ; Print how many rows got affected by latest query ConsoleWrite(StringFormat("Number of rows to display: %s", .rowCount()) & @CRLF) ; we use isObj to check if we got any result. If IsObj($oRows) Then For $row In $oRows ConsoleWrite(StringFormat("Id: %s", $row.id) & @CRLF) ConsoleWrite(StringFormat("Name: %s", $row.name) & @CRLF) ConsoleWrite(StringFormat("Bio: %s", $row.bio) & @CRLF) Next Else ConsoleWrite("No rows to show"&@CRLF) EndIf EndWith ; Use this in your app when you are done using the database $MySql.Shutdown() #include <miniSQL\miniSQL.au3> ; Set default dir for our dlls (Only has to be done once) _miniSQL_setDllDir(@ScriptDir & "\miniSQL") ; Declared as CONST since we never want to accidentally change the variables original value Local Const $MySql = _miniSQL_LoadLibrary() ;Connect to database & Init library If Not $MySql.Startup("localhost", "user", "pass", "db", 3306) Then MsgBox(0, "Failed to start library", $MySql.debug()) Exit EndIf With $MySql ; We use an array to make our query look nicer Local $vars = [":name", @UserName&Random(1,10,1)] ; Prepare our statement .prepare("UPDATE members SET name = :name WHERE 1") If Not .execute($vars) Then MsgBox(0, "Failed to execute query", .sqlError()) ; Print how many rows got affected by latest query ConsoleWrite(StringFormat("Example 1 rows affected: %s", .rowCount()) & @CRLF) EndWith ; We can also prepare like this With $MySql Local $vars = ["?", @UserName, "?", 1] ; Prepare our statement .prepare("UPDATE members SET name = ? WHERE id = ?") If Not .execute($vars) Then MsgBox(0, "Failed to execute query", .sqlError()) ; Print how many rows got affected by latest query ConsoleWrite(StringFormat("Example 2 rows affected: %s", .rowCount()) & @CRLF) EndWith ; Use this in your app when you are done using the database $MySql.Shutdown() With $MySql ; We use an array to make our query look nicer Local $vars = ["?", 1] ;Line by line prepared statement .prepareClean(); .prepareGlue("SELECT *") .prepareGlue("FROM members") .prepareGlue("WHERE id = ?") If Not .execute($vars) Then MsgBox(0, "Failed to execute query", .sqlError()) ; Print how many rows got affected by latest query ConsoleWrite(StringFormat("Example 1 rows affected: %s", .rowCount()) & @CRLF) EndWith ; Use this in your app when you are done using the database $MySql.Shutdown() Some code from one of my applications at work using this UDF With $MySql .prepareClean() .prepareGlue("SELECT") .prepareGlue("cases.cases_dedu_casenumber,") .prepareGlue("cases.cases_created_by_ugid,") .prepareGlue("cases.cases_dedu_ftg,") .prepareGlue("cases.cases_date_created,") .prepareGlue("cases.cases_date_finished,") .prepareGlue("cases.cases_protocol_director,") .prepareGlue("cases.cases_finished_by_ugid,") .prepareGlue("IFNULL(uid1.names_name, 'none') as createdByFullname,") .prepareGlue("IFNULL(uid2.names_name, 'none') as finishedByFullname") .prepareGlue("FROM cases") .prepareGlue("LEFT JOIN names AS uid1") .prepareGlue("ON cases.cases_created_by_ugid = uid1.names_uid") .prepareGlue("LEFT JOIN names AS uid2") .prepareGlue("ON cases.cases_finished_by_ugid = uid2.names_uid") if $_App_Case_SearchFor Then .prepareGlue(StringFormat("WHERE cases_dedu_casenumber LIKE '%s'",$_App_Case_SearchFor)) .prepareGlue("ORDER BY cases.cases_date_created DESC") .prepareGlue("LIMIT 0, 30") if not .execute() then return __ThrowException(.sqlError()) Local $oRows = .fetchAll() EndWith Git: https://gitlab.com/xdtarrexd/MiniSQL.git Download: Zip generated from Github Feel free to open your mind about this
    1 point
  12. Someone told me I should post this in the examples section. I wrote this to make it easy for me to call a Windows console application and get its output using a single line of AutoIt code. I hope it's helpful to someone else. #include <Constants.au3> ; Examples: MsgBox(0,"Windows Version",_RunWaitGet(@ComSpec & " /c ver",1,"",@SW_HIDE)) MsgBox(0,"System Info",_RunWaitGet(@SystemDir & "\systeminfo.exe",1)) ; #FUNCTION# ==================================================================================================================== ; Name ..........: _RunWaitGet ; Description ...: Runs the specified process, waits for it to exit, then returns the contents of its StdOut and/or StdErr streams. ; Handy for running command-line tools and getting their output. ; Syntax ........: _RunWaitGet($sProgram, $nOptions, $sWorkingDir, $nShowFlag) ; Parameters ....: $sProgram - The full path of the program (EXE, BAT, COM, or PIF) to run ; $nOptions - Add options together: ; 1 = Capture the StdOut stream. ; 2 = Capture the StdErr stream. ; 4 = Return when the stream(s) close(s), not when the process ends. ; $sWorkingDir - The working directory. Blank ("") uses the current working directory. ; This is not the path to the program. ; $nShowFlag - The "show" flag of the executed program: ; @SW_SHOW = Show window (default) ; @SW_HIDE = Hidden window (or Default keyword) ; @SW_MINIMIZE = Minimized window ; @SW_MAXIMIZE = Maximized window ; Return values .: String value containing the captured contents. ; If there was a problem running the process, @error is set to the @error value returned by Run(). ; Otherwise, @error is 0. ; Author ........: ToasterKing ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: MsgBox(0,"System Info",_RunWaitGet(@SystemDir & "\systeminfo.exe",1)) ; MsgBox(0,"Windows Version",_RunWaitGet(@ComSpec & " /c ver",1,"",@SW_HIDE)) ; =============================================================================================================================== Func _RunWaitGet($sProgram,$nOptions = 0,$sWorkingDir = @SystemDir,$nShowFlag = @SW_SHOW) Local $nRunOptFlags = 0,$sStreamOut = "" ; Initialize variables ; Determine flags for parent/child interaction If BitAND($nOptions,1) Then $nRunOptFlags += $STDOUT_CHILD If BitAND($nOptions,2) Then $nRunOptFlags += $STDERR_CHILD Local $hRunStream = Run($sProgram,$sWorkingDir,$nShowFlag,$nRunOptFlags) ; Run the process If @error Then Return SetError(@error,@extended,0) ; If there was an error code, return it. Otherwise... While 1 ; Loop until the end of the stream, which indicates that the process has closed it (which usually means the process ended) If BitAND($nOptions,1) Then ; If user specified to capture STDOUT stream... $sStreamOut &= StdoutRead($hRunStream) ; Append new stream contents to existing variable while removing those contents from the stream. If @error = 2 And BitAND($nOptions,4) Then ExitLoop ; If stream ended and user specified to return when the stream closes, stop looping. EndIf If BitAND($nOptions,2) Then ; If user specified to capture STDERR stream... $sStreamOut &= StderrRead($hRunStream) ; Append new stream contents to existing variable while removing those contents from the stream. If @error = 2 And BitAND($nOptions,4) Then ExitLoop ; If stream ended and user specified to return when the stream closes, stop looping. EndIf If Not BitAND($nOptions,4) And Not ProcessExists($hRunStream) Then ExitLoop ; If using the default setting and the process ended, stop looping. Sleep(100) ; To avoid overloading the CPU WEnd Return SetError(0,0,$sStreamOut) ; Return the captured contents and @error = 0 EndFunc
    1 point
  13. Take a few steps backwards here. The few that will get you to before you joined the forums. EDIT: I hate it when for the sake of politness I have to use so many words. I could have easily done that statement in just 2.
    1 point
  14. something like $drive = StringMid(@ScriptDir,1,1) Run($drive & ":\New folder\a\setup.exe")
    1 point
×
×
  • Create New...