Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/03/2020 in all areas

  1. We're back in business. Tonight I've installed the latest version of Visual Studio, the WebView2 GitHub sample files and the WebView2 NuGet package as described in the documentation for the WebView2 getting started example. Step 1 - 3 in the documentation. After a single small error, the build process succeeded in the second attempt. The executable WebView2 file started automatically (the Bing search shown in the image in the documentation), I searched for "autoit forums" and then browsed through exactly this thread. So now we have code that works on Windows 10, we have code that can be translated into AutoIt, and we have the WebView2.h header file from the NuGet package that seems to contain all the information needed to create tag description files for ObjCreateInterface() and ObjectFromTag(). I've once again changed the priority of my projects. They are all exciting. But this is the most exciting right now. Already this weekend, I hope to be able to take the first steps in the translation task. HelloWebView.cpp and WebView2.h are contained in the 7z-file. WebView2.7z
    2 points
  2. Anybody could help with using QueryInterface in AutoIt to embed Microsoft Edge using WebView2 Interface ? Here are links to information/documentation: Image comes from: https://docs.microsoft.com/en-us/microsoft-edge/webview2/media/webview2/whatwebview.png Introduction to Microsoft Edge WebView2 https://docs.microsoft.com/en-us/microsoft-edge/webview2/ Understand WebView2 SDK versions https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/versioning Download: https://developer.microsoft.com/en-US/microsoft-edge/webview2/ https://developer.microsoft.com/en-US/microsoft-edge/webview2/#download-section https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution API Reference: https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/?view=webview2-1.0.622.22 HowTo/Concepts: https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/versioning https://docs.microsoft.com/en-us/microsoft-edge/webview2/gettingstarted/win32 https://docs.microsoft.com/en-us/microsoft-edge/webview2/howto/debug?tabs=devtools https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/security https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/userdatafolder https://mybuild.microsoft.com/sessions/9198aeac-0c8e-4d32-96d1-cbb99a390aa6 Example: https://github.com/MicrosoftEdge/WebView2Samples Related: https://www.essentialobjects.com/Products/WebBrowser/Default.aspx?gclid=CjwKCAiA17P9BRB2EiwAMvwNyMe6UI9VHej-JYDBUoyGDFz40KaaJ_RidY-75Fhr-PHz65sSVC0XlxoC5loQAvD_BwE https://docs.microsoft.com/en-us/microsoft-edge/webview2/howto/webdriver btw. I'm not WindowsApi expert (QueryInterface, C++, DllCall). What I trying to say is: It means that I do not done anything in this regards .... as so far. TIMELINE/ChangeLog: 2020-11-12 - Project propsed by @mLipok 2021-02-03 - First version provided by @LarsJ
    1 point
  3. EasyCodeIt A cross-platform implementation of AutoIt Introduction: EasyCodeIt is an attempt at implementing a programming language which is backward compatible with a sub-set of AutoIt which would work across multiple platforms with many aspects being agnostic to the platform-specific differences. Currently the primarily targeted platforms are Linux and Windows, more platforms may be supported in the future as per popular demand. For example it should be easy enough to port to Unix-like platforms such as BSD and Mac with the help of maintainers who are familiar with them. The main motivation behind the creation of this project is the lack of a proper easy-to-use scripting language in Linux, while there are numerous scripting languages which natively support it, none of them are as user-friendly and easy to use as AutoIt. (The "Easy" in "EasyCodeIt" reflects this) There was a previous thread in which the project was originally started, but it got too big and the discussion is too cluttered and hard to follow for any new readers, here is the thread for those who are interested in reading it: Progress: Frontend ✅ Tokenizer 🚧 Parser (work in progress) ✅ Expressions 👷‍♂️ Statements (current priority) Backend ⏰ Interpreter (scheduled) I am currently working on expression parsing and syntax tree building. -- This section will be updated in the future with new progress. To stay notified 🔔 follow this thread to get update notifications (by using the "Follow" button on the top-right corner of this page) and 👁️ watch the GitHub repository to get any new activity on your feed. Code: The code is available on GitHub, please 🌟 star the project if you like it and would like to show your support, it motivates me a lot! (Also don't forget to 👍 Like this post ) Chat: I created a room in Matrix (an open-source federated chat system) for EasyCodeIt, you can join it to chat with me and others who are in the room, it might be a good way to get the latest status updates from me You can preview the room without joining, and you don't need to be connected to it 24/7 like IRC. It works a bit like Slack for those who are familiar with it. Forum: I have created a dedicated forum to post more frequent updates, possibly in their own threads to better organize the discussion. Please sign-up and follow the blog section to get updates. By the way, you can also post pretty much anything there, both technical and non-technical stuff, it is intended to be a hangout for techies but not only for them. So casual discussions, funny cat videos etc. are allowed!
    1 point
  4. BYTE *bPort, BYTE* inRBuff, *see above
    1 point
  5. Might as well skip the if altogether and just say: Sleep(1000 * ProcessClose($process))
    1 point
  6. This example is about implementing Rectangular Selection in a listview with mouse and keyboard. By default, listviews only supports selection of entire rows. Either a single row or multiple rows. The purpose of this UDF is also to support selection of a rectangular group of cells. Either a single rectangular group of cells or multiple rectangular groups of cells. The UDF supports all four types of listviews: The conventional (all examples in the help file), virtual (includes the $LVS_OWNERDATA style), ownerdrawn (includes the $LVS_OWNERDRAWFIXED style) and ownerdrawn+virtual listview. The examples are all about virtual listviews to verify that the code still works with a large number of additional WM_NOTIFY messages needed to populate a virtual listview. One additional message per cell for all cells visible on a listview page. If a page shows 40 rows and 15 columns, this means 600 additional messages to fill the page with data. The first post here is about selecting a single rectangular group of cells. The next post is about selecting multiple rectangular groups of cells. Single selectionSelecting a single rectangular group of cells forming a rectangular selection can be performed by selecting the first corner cell of the rectangle as a fixed starting cell and then selecting the opposite corner cell of the rectangle based on the Single Cell Navigation technique. The technique of creating a single rectangular selection in this post and of creating multiple rectangular selections in the next post is heavily based on the Single Cell Navigation (SCN) UDF. The ideas in code to implement resizable GUIs and listviews and the use of multiple listviews are exactly the same in terms of Rectangular Selections as they are in terms of Single Cell Navigation. And the requirements for a listview to implement Rectangular Selections are the same as the requirements for implementing Single Cell Navigation: The $LVS_EX_HEADERDRAGDROP style (drag/drop reordering of columns) is not supported. Zero-width columns are not supported. In the code it's checked that columns are not narrower than 10 pixels. ExampleThis is the Virtual-SRS.au3 example. The example demonstrates the use of the pure UDF. The rectangle selection is not used in user code. Run the example in SciTE with F5. Right-click listview and select "Single rectangle selection". You should try to create a selection using all four methods described below: The yellow cell is the active cell that is subject of keyboard navigation. There are four ways to create a rectangle selection. Click and drag a selection with the mouse. Releasing the mouse button completes the selection. The advantage of this method is that it's simple, fast and intuitive. The disadvantage is that it can only be used to make a selection on the current visible page in the listview. When using the mouse to create the selection, you cannot use the mouse on the scrollbars at the same time. The other three ways uses the Shift key to create the selection. This allows you to continue a selection by pressing the Shift key and performing single cell navigation on the yellow active cell in one of the corners of the current selection. You can also continue a selection started with the Click and drag method above. The ability to continue a selection allows you to create large selections that span multiple listview pages and navigate the listview with the scrollbars in between each subselection. The three methods with the Shift key are fully integrated. You can start a selection with one method and continue with another method. The yellow active cell is the fixed start cell in the selection rectangle. Press the Shift key and Use keyboard navigation to create the selection rectangle. Click the opposite corner of the selection rectangle with the mouse. Using the scrollbars, you can navigate around the listview before clicking the opposite corner. Click and drag a selection with the mouse. Releasing Shift key and mouse button temporarily completes the selection. Since only a single rectangle selection is supported, a click of the mouse, a movement of the yellow active cell with the keyboard or starting a new selection will immediately delete the current selection. The codeSingle Rectangle Selection (SRS) is implemented as a UDF in Includes\GuiListViewSRS.au3. GuiListViewSRS.au3 was started as a direct copy of GuiListViewSCN.au3. The UDF contains two functions to enable and disable SRS functionality. The functions starts and stops two message handlers implemented through the subclassing technique that takes care of the actual Single Rectangle Selection. One message handler, SRS_GuiHandler(), takes care of WM_NOTIFY messages (listview and header notifications and messages) sent to the main GUI. The other message handler, SRS_ListViewHandler(), takes care of mouse and keyboard messages sent directly to the listview. ExamplesRun examples in SciTE with F5. There are only two examples of single rectangle selections. Virtual-SRS.au3 is the example shown above. Virtual-SRS-Ex.au3 is a very simple example of using the rectangle selection in the user code. It's used to draw a corresponding rectangle in the user code. Right-click listview and select "Single rectangle selection" to switch to UDF code. Create a rectangle selection. Right-click listview and select "Default row selection" to switch back to user code. Because the UDF only supports single selections, the rectangle is passed to the user code as item/subitem (row/column) coordinates (indexes) of two opposite corner cells in the rectangle. This means that even a very large rectangle is passed instantly. You should see the rectangel in the user code. 7z-fileThe 7z-file contains source code for UDFs and examples. You need AutoIt 3.3.12 or later. Tested on Windows 7 and Windows 10. Comments are welcome. Let me know if there are any issues. RectangularSelection.7z
    1 point
  7. This example is about Single Cell Navigation in a listview with mouse and keyboard. By default, listviews only supports navigation through the rows. The purpose of this UDF is also to support navigation through the cells. The UDF supports all four types of listviews: The conventional (all examples in the help file), virtual (includes the $LVS_OWNERDATA style), ownerdrawn (includes the $LVS_OWNERDRAWFIXED style) and ownerdrawn+virtual listview. However, the 7z-file at bottom of post only contains examples for conventional and virtual listviews. ExampleThis is the Virtual\Resizable2.au3 example. Run the example in SciTE with F5. Right-click listview and select "Single cell navigation": The yellow cell is the active cell that is subject of keyboard navigation. Mouse navigation: Click a listview cell. Vertical keyboard navigation: Up, Down, PageUp, PageDown, Home and End. Horizontal keyboard navigation: Left, Right, CapsLock + PageUp, PageDown, Home or End. If the yellow active cell is located outside the visible page in the listview (if eg. a scrollbar has been used), using a navigation key will again place the active cell on the visible page. CapsLock is used for horizontal navigation because both Shift and Ctrl are used for standard multiple row selection. CapsLock + PageUp, PageDown, Home or End is especially interesting for ownerdrawn+virtual listviews that supports many columns. Horizontal or vertical navigation one page at a time can generate a lot of flicker. To prevent excessive flicker, automatic repeat of the PageUp/PageDown keys is disabled. A large amount of code is used to ensure that when a cell in a only partially visible (or not visible at all) column along a listview edge becomes the active cell, then the entire column and thus the cell becomes fully visible. Both in the UDF and in the examples, a large amount of code has also been used on the topic of GUI and listview resizing. ResizingFor a large control like a listview, it's usually valuable that both the GUI and the listview are resizable. And for a listview, it's nice if the height always fits an integer number of rows. If a column is made wider or narrower by dragging the header divider so that the horizontal scrollbar appears or disappears, then the height of the listview must be adjusted a little so that it again corresponds to an integer number of rows. The UDF to some extent support resizing in relation to these assumptions. But only for a single listview. If you need multiple listviews in the same GUI that all offers single cell navigation, then disable resizing in single cell navigation mode (remove resizing in GUI style and remove column resizing in listview header style (Virtual\Resizable4.au3)). Then you can handle resizing completely in your own code. RequirementsImplementing the functionality described above already requires quite a lot of code. In order not to use too much code, the following requirements for a listview must be met in order to use the UDF: The $LVS_EX_HEADERDRAGDROP style (drag/drop reordering of columns) is not supported. Zero-width columns are not supported. In the code it's checked that columns are not narrower than 10 pixels. The codeThe code is based on the KeyboardNavigation and MarkCurrentCell examples in the multi-column listviews thread. And these examples are again based on this old example of cell editing. In the new thread here, the Single Cell Navigation (SCN) functionality is implemented as a UDF in Includes\GuiListViewSCN.au3. The UDF contains two functions to enable and disable SCN functionality. In addition to the usual housekeeping code, the functions starts and stops two message handlers implemented through the subclassing technique that takes care of the actual Single Cell Navigation. One message handler, SCN_GuiHandler(), takes care of WM_NOTIFY messages (listview and header notifications and messages) sent to the main GUI. The other message handler, SCN_ListViewHandler(), takes care of mouse and keyboard messages sent directly to the listview. Because the code is very much about message handling, Windows Message Monitor has been an important tool for developing the UDF. ExamplesRun all examples in SciTE with F5. Virtual listviews FirstTest.au3, Incompatible.au3, MultipleLists.au3 and Non-Resizable.au3 are all non-resizable. And it's not possible to change column widths. FirstTest.au3 is a very simple example that immediately starts up in single cell navigation mode. Non-Resizable.au3 is similar to FirstTest.au3, but single cell navigation can be enabled/disabled dynamically through the listview context menu. Incompatible.au3 is incompatible with single cell navigation due to the $LVS_EX_HEADERDRAGDROP style. An error is generated when you right-click to enable single cell navigation. MultipleLists.au3 demonstrates how to use single cell navigation in multiple listviews. Right-click listviews to enable/disable single cell navigation. In Resizable1.au3, the width of GUI and listview corresponds to the width of the columns. If you increase/decrease the width of a column or the width of the GUI a little bit, the horizontal scrollbar will appear/disappear. Resizable2.au3 is the example shown above. It's used to test horizontal navigation. Resizable3.au3 demonstrates how to handle resizing when the GUI contains more controls than just the listview. Resizable4.au3 shows how to disable resizing in single cell navigation mode. Then you can handle all resizing in your own code. Conventional listviews The examples for conventional listviews are similar to the examples for virtual listviews with the same names. UsageSingle cell navigation can be used for many different purposes. Here it'll be used to implement Rectangular Selection in ListView. 7z-fileThe 7z-file contains source code for UDFs and examples. You need AutoIt 3.3.12 or later. Tested on Windows 7 and Windows 10. Comments are welcome. Let me know if there are any issues. CellNavigation.7z
    1 point
  8. 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
  9. Hello, I am a begginer when it comes down to scripting and programming. I have not been able to find a thread covering a problem i encountered, nor a working solution. Is it possible to include a function, as an array element? I imagine it working like this: #include <MsgBoxConstants.au3> #inlude <Array.au3> Global $Array [5] = ["5", "4", _Function2(), "2", "1" ] While 1 _Function1() WEnd Func _Function1() For $i=1 to 5 MsgBox ($MB_OK, "", $Array[$i]) Next EndFunc Func _Function2() MsgBox ($MB_OK, "", "Function was executed") EndFunc Thanks
    1 point
  10. Thank you guys for the help. I was unable to get my sript working using the method described in replies. Fortunately i found a workaround, using some of the techniques. Below is my method: #include <MsgBoxConstants.au3> #include <Array.au3> HotKeySet("{ESC}", "_Exit") Global $Array[5] = ["5", "4", _Function2, "2", "1"] While 1     _Function1() WEnd Func _Function1 () For $i=1 to 5 $element = IsFunc($Array[$i]) If $element = 0 Then MsgBox ($MB_OK, "", $Array[$i]) Else Call($Array[$i]) EndIf Next EndFunc   ;==>_Function1 Func _Function2()     MsgBox ($MB_OK, "", "Function was executed") EndFunc Func _Exit()     Exit EndFunc
    1 point
  11. VeryGut, An alternate and more readable technique... #include <MsgBoxConstants.au3> #include <Array.au3> ; define 50 element array anf fill with sequential integers Global $Array[50] For $1 = 0 To UBound($Array) - 1 $Array[$1] = $1 Next _Function1() Func _Function1() For $i = 0 To UBound($Array) - 1 ConsoleWrite(StringFormat('$i = %02i\tmod value = %02i', $i, Mod($i, 10)) & @CRLF) ;every 10th entry run the cleanup routine If Mod($i, 10) = 0 And $i <> 0 Then _Function2() Next EndFunc ;==>_Function1 Func _Function2() ConsoleWrite('Ran cleanup' & @CRLF) EndFunc ;==>_Function2 kylomas
    1 point
  12. VeryGut, Welcome to the AutoIt forums. You can indeed use a function in an array - like this: #include <MsgBoxConstants.au3> HotKeySet("{ESC}", "_Exit") Global $Array[5] = ["5", "4", _Function2, "2", "1"] While 1 _Function1() WEnd Func _Function1() For $i = 0 To 4 MsgBox($MB_OK, "", ( (IsFunc($Array[$i])) ? ($Array[$i]()) : ($Array[$i]) )) Next EndFunc ;==>_Function1 Func _Function2() Return "Function was executed" EndFunc ;==>_Function2 Func _Exit() Exit EndFunc You need to check that the array element is a function and then add the trailing () to execute it. Out of interest, why do you need to do this? M23
    1 point
  13. When you create an input box you can set the length of characters, digits only, Uppercase, Center like this. GUICtrlCreateInput Style Options $ES_NUMBER == Accepts only digits [0-9] $ES_UPPERCASE == Converts all characters to uppercase $ES_LOWERCASE == Converts all characters to lowercase $ES_CENTER == Centers text GUICtrlSetLimit ( controlID, max , OPTIONAL min ) == so you can set a max and min character length for an input control  $UserInput = GUICtrlCreateInput("", 120, 292, 161, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER,$ES_NUMBER))   GUICtrlSetLimit($UserInput, 10) ; Limit User Input to 10 Characters, can also just use -1 instead of variable of input box if this line is directly under like here
    1 point
  14. This should work to do it dynamically #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> Opt("GUIOnEventMode", 1) $hGUI = GUICreate("Test", 232, 90) $Label = GUICtrlCreateLabel("Enter MAC address", 22, 8, 163, 17) $input = GUICtrlCreateInput("", 22, 30, 165, 24) GUICtrlSetLimit(-1, 17) GUICtrlSetFont(-1, 12) GUISetState() GUIRegisterMsg($WM_COMMAND, '_WM_COMMAND') GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") While 1 Sleep(10) WEnd Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local $id = BitAND($wParam, 0x0000FFFF) Local $code = BitShift($wParam, 16) If $id = $input AND $code = $EN_UPDATE Then Local $content = GUICtrlRead($input) Local $len = StringLen($content) Local $char = StringRight($content, 1) Local $mod = Mod($len, 3) If not (( ($mod = 1 or $mod = 2) and StringRegExp($char, '[[:xdigit:]]') ) OR _ ($mod = 0 and $char = "-")) Then GUICtrlSetData($input, StringTrimRight($content, 1)) EndIf Return $GUI_RUNDEFMSG EndFunc Func _Exit() Exit EndFunc
    1 point
  15. I'm trying to make a GUI interface that recieves data from my Archangel.ini as default, but can be changed and then saved to the .ini from the GUI program. I'm having trouble creating the save button function that actually writes to the .ini file. Any help would be much appreciated. My ConfigurationGUI.au3 #include <GlobalVars.au3> #include <ArchLib.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <WindowsConstants.au3> #include <GuiButton.au3> #include <StaticConstants.au3> #include <EditConstants.au3> Global $ButtonSave, $ButtonCancel, $msg, $PRI1, $PRI2, $PRI3, $PRI4, $PRI5, $PRI6, $PRI7, $PRI8, $PRI9, $PRI10, $msg2 DecodeIni("Archangel.Ini", False) ;Decodes the .Ini File ;ConsoleWrite($IniProgramGroup & @CR) GUICreate("Archangel Configuration Setup", 500, 400) ;Creates the GUI window GUISetBkColor(0x00E0eeeF) ;Sets Background color $ButtonSave = GUICtrlCreateButton("Save", 200, 350, 45, 30) ;Save button $ButtonCancel = GUICtrlCreateButton("Cancel", 300, 350, 45, 30) ;Cancel Button GUICtrlCreateTab(0, 0, 500, 340) ;Creates the tab GUICtrlCreateTabItem("Speed") ;First tab item GUICtrlCreateLabel("Speed Settings", 10, 25) ;Creates the label for the configuration drop down menu GUICtrlCreateLabel("Show the Speed:", 10, 100) ;Creates the label for the Show the speed config GUICtrlCreateLabel("Speed limit:", 10, 175) ;Creates the label for the Speed limit config GUICtrlCreateCombo("", 275, 100) ;Creates the drop down box GUICtrlSetData(10, "Yes|No", $ShowSpeed) ;Puts the data into the drop down box GUICtrlCreateCombo("", 275, 175) ;Creates the drop down box GUICtrlSetData(11, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30", $SpeedLimit) ;Puts the data into the drop down box GUICtrlCreateTabItem("Serial Settings") ;Tab with serial settings GUICtrlCreateLabel("Serial Settings", 10, 25) ;Creates the label for the serial settings GUICtrlCreateLabel("Communications Port:", 10, 75) ;Creates the label for the commport setting GUICtrlCreateLabel("Baudrate:", 10, 150) ;Creates the label for the Baudrate GUICtrlCreateCombo("", 275, 75) ;Creates the drop down box GUICtrlSetData(16, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50", $NumericPort) ;Puts data into drop down box GUICtrlCreateCombo("", 275, 150) ;Creates drop down box GUICtrlSetData(17, "2400|4800|9600|19200|38400|57600|115200|31250", $BaudRate) ;Puts data into drop down box GUICtrlCreateTabItem("Accesories") ;keyboard, mouse, touchscreen options GUICtrlCreateLabel("Accesories settings", 10, 25) ;Creates label for accesories settings GUICtrlCreateLabel("Block options:", 10, 75) ;Creates the label for the block options GUICtrlCreateCombo("", 275, 75) ;Creates the dorp down box GUICtrlSetData(21, "None|Both|Mouse/Touchscreen|Keyboard", $AlphaBlock[$BlockOption]) ;Puts data into drop down box GUICtrlCreateTabItem("Run Plates") ;Run plate option tab GUICtrlCreateLabel("Ability to run plates", 10, 25) ;creates label for plate running config GUICtrlCreateLabel("Run Plates", 10, 75) ;creates the label for plate running setting GUICtrlCreateCombo("", 275, 75) ;creates drop down box GUICtrlSetData(25, "Yes|No", $RunPlates) ;puts data into drop down box GUICtrlCreateTabItem("Windows Priority") ;windows priority tab GUICtrlCreateLabel("Select Windows Priority", 10, 25) ;creates label for windows priority config GUICtrlCreateLabel("Priority 1:", 10, 40) ;creates label for windows priority 1 GUICtrlCreateLabel("Maximize:", 100, 40) ;creates label for maximize window GUICtrlCreateLabel("Priority 2:", 10, 80) ;creates label for windows priority 2 GUICtrlCreateLabel("Maximize:", 100, 80) ;creates label for maximize window GUICtrlCreateLabel("Priority 3:", 10, 120) ;creates label for windows priority 3 GUICtrlCreateLabel("Maximize:", 100, 120) ;creates label for maximize window GUICtrlCreateLabel("Priority 4:", 10, 160) ;creates label for windows priority 4 GUICtrlCreateLabel("Maximize:", 100, 160) ;creates label for maximize window GUICtrlCreateLabel("Priority 5:", 10, 200) ;creates label for windows priority 5 GUICtrlCreateLabel("Maximize:", 100, 200) ;creates label for maximize window GUICtrlCreateLabel("Priority 6:", 200, 40) ;creates label for windows priority 6 GUICtrlCreateLabel("Maximize:", 300, 40) ;creates label for maximize window GUICtrlCreateLabel("Priority 7:", 200, 80) ;creates label for windows priority 7 GUICtrlCreateLabel("Maximize:", 300, 80) ;creates label for maximize window GUICtrlCreateLabel("Priority 8:", 200, 120) ;creates label for windows priority 8 GUICtrlCreateLabel("Maximize:", 300, 120) ;creates label for maximize window GUICtrlCreateLabel("Priority 9:", 200, 160) ;creates label for windows priority 9 GUICtrlCreateLabel("Maximize:", 300, 160) ;creates label for maximize window GUICtrlCreateLabel("Priority 10:", 200, 200) ;creates label for windows priority 10 GUICtrlCreateLabel("Maximize:", 300, 200) ;creates label for maximize window GUICtrlCreateCombo("", 100, 55) ;Drop down box for maximize selection GUICtrlSetData(48, "Yes|No", $IniMaximize[1]) ;puts data into drop down box for maximize selection GUICtrlCreateCombo("", 100, 95) ;Drop down box for maximize selection GUICtrlSetData(49, "Yes|No", $IniMaximize[2]) ;puts data into drop down box for maximize selection GUICtrlCreateCombo("", 100, 135) ;Drop down box for maximize selection GUICtrlSetData(50, "Yes|No", $IniMaximize[3]) ;puts data into drop down box for maximize selection GUICtrlCreateCombo("", 100, 175) ;Drop down box for maximize selection GUICtrlSetData(51, "Yes|No", $IniMaximize[4]) ;puts data into drop down box for maximize selection GUICtrlCreateCombo("", 100, 215) ;Drop down box for maximize selection GUICtrlSetData(52, "Yes|No", $IniMaximize[5]) ;puts data into drop down box for maximize selection GUICtrlCreateCombo("", 300, 55) ;Drop down box for maximize selection GUICtrlSetData(53, "Yes|No", $IniMaximize[6]) ;puts data into drop down box for maximize selection GUICtrlCreateCombo("", 300, 95) ;Drop down box for maximize selection GUICtrlSetData(54, "Yes|No", $IniMaximize[7]) ;puts data into drop down box for maximize selection GUICtrlCreateCombo("", 300, 135) ;Drop down box for maximize selection GUICtrlSetData(55, "Yes|No", $IniMaximize[8]) ;puts data into drop down box for maximize selection GUICtrlCreateCombo("", 300, 175) ;Drop down box for maximize selection GUICtrlSetData(56, "Yes|No", $IniMaximize[9]) ;puts data into drop down box for maximize selection GUICtrlCreateCombo("", 300, 215) ;Drop down box for maximize selection GUICtrlSetData(57, "Yes|No", $IniMaximize[10]) ;puts data into drop down box for maximize selection $PRT1 = GUICtrlCreateCombo("", 10, 55) ;Drop down box for priority input GUICtrlSetData(58, "Spillman Mobile|None|Example1|Example2", $IniPriority[1]) ;puts data into drop down box for priority input/selection $PRT2 = GUICtrlCreateCombo("", 10, 95) ;Drop down box for priority input GUICtrlSetData(59, "Spillman Mobile|None|Example1|Example2", $IniPriority[2]) ;puts data into drop down box for priority input/selection $PRT3 = GUICtrlCreateCombo("", 10, 135) ;Drop down box for priority input GUICtrlSetData(60, "Spillman Mobile|None|Example1|Example2", $IniPriority[3]) ;puts data into drop down box for priority input/selection $PRT4 = GUICtrlCreateCombo("", 10, 175) ;Drop down box for priority input GUICtrlSetData(61, "Spillman Mobile|None|Example1|Example2", $IniPriority[4]) ;puts data into drop down box for priority input/selection $PRT5 = GUICtrlCreateCombo("", 10, 215) ;Drop down box for priority input GUICtrlSetData(62, "Spillman Mobile|None|Example1|Example2", $IniPriority[5]) ;puts data into drop down box for priority input/selection $PRT6 = GUICtrlCreateCombo("", 200, 55) ;Drop down box for priority input GUICtrlSetData(63, "Spillman Mobile|None|Example1|Example2", $IniPriority[6]) ;puts data into drop down box for priority input/selection $PRT7 = GUICtrlCreateCombo("", 200, 95) ;Drop down box for priority input GUICtrlSetData(64, "Spillman Mobile|None|Example1|Example2", $IniPriority[7]) ;puts data into drop down box for priority input/selection $PRT8 = GUICtrlCreateCombo("", 200, 135) ;Drop down box for priority input GUICtrlSetData(65, "Spillman Mobile|None|Example1|Example2", $IniPriority[8]) ;puts data into drop down box for priority input/selection $PRT9 = GUICtrlCreateCombo("", 200, 175) ;Drop down box for priority input GUICtrlSetData(66, "Spillman Mobile|None|Example1|Example2", $IniPriority[9]) ;puts data into drop down box for priority input/selection $PRT10 = GUICtrlCreateCombo("", 200, 215) ;Drop down box for priority input GUICtrlSetData(67, "Spillman Mobile|None|Example1|Example2", $IniPriority[10]) ;puts data into drop down box for priority input/selection GUISetState(@SW_SHOW) ;Shows the GUI window ;MsgBox(2, "Checker", $PRT1) ;Checks the ControlID ;MsgBox(2, "error detection", $DataSelect) ;error detection(combo 4) ;Makes cancel button and the close button(top right x) close the program While -1 $msg = GUIGetMsg() Select Case $msg = $ButtonCancel Or $msg = $GUI_EVENT_CLOSE Case "Show the speed" If "Yes" Or "No" Then FileWriteLine("Archangel.ini", 10) EndIf ExitLoop EndSelect WEnd My GlobalVars.au3 ; Path Variables Global $IniName = "Archangel.ini" Global $ProgramDir = @ProgramFilesDir & "\Archangel" ;From ini Global $IniProgramGroup = "" Global $IniVersion = "" Global $ShowSpeed = "No" Global $CommPort = "" Global $NumericPort Global $BaudRate = 9600 Global $SpeedLimit = 15 Global $ClearOnTop = "No" Global $IniFiles, $IniFileName[10] Global $IniPriorities, $IniPriority[11], $IniMaximize[11] Global $RunPlates = "No" Global $BlockOption = 1 Global $BlockMouse = True Global $AlphaBlock[4] $AlphaBlock[0] = "None" $AlphaBlock[1] = "Both" $AlphaBlock[2] = "Mouse/TouchScreen" $AlphaBlock[3] = "Keyboard" ; Log Variables Global $LogHandle = -1 Global $LogError = False Global $LogDetail = "No" Global $LogFile = "" Global $Sequence = "Init" ; Log / Error / Debugs Global $Debug = False Global $IsErrorFatal = "No", $ErrorTitle = "", $ErrorMessage = "" ; Miscellaneous Const $SpeedCursor = "Current speed is " Global $LenSpeedCursor = StringLen($SpeedCursor) Global $SFResult[2] $SFResult[0] = "failed" $SFResult[1] = "successful" ; Speed Variables Global $LastSpeed = 0 ; Communications to Herbie Global $Kernel32Handle = -1 Global $SerialPortHandle = -1 Global $DCB_Struct = "" Global $CommTimeout = "" Global $CommTimeout_Struct = "" Global $CommState = "" Global $CommState_Struct = "" Global $HerbieError = False Global $ReceivedFromHerbie = "" Global $SpeedValidation = "410D" Global $CurrentSpeed = 0 ; SDX Dongle Global $SDXHandle = -1 Global $tSDXHID = DllStructCreate("DWORD") My Archlib.au3 Func DecodeIni($FullIniPath, $LogIt) Local $NotFound = "Not Found", $Result = 0, $Index = 0 $ErrorTitle = "Error Reading Initialization File" $ErrorMessage = $FullIniPath $IsErrorFatal = True $IniProgramGroup = IniRead($FullIniPath, "Version", "ProgramGroup", $NotFound) If $IniProgramGroup = $NotFound Then MyError() EndIf $IniVersion = IniRead($FullIniPath, "Version", "VersionNumber", $NotFound) If $IniVersion = $NotFound Then _MyError() EndIf $NumericPort = IniRead($FullIniPath, "Communication", "Port", $NotFound) If $IniVersion = $NotFound Then _MyError() EndIf $CommPort = "COM" & $NumericPort If ($NumericPort > 9) Then $CommPort = "\\.\" & $CommPort EndIf $BaudRate = IniRead($FullIniPath, "Communication", "Baudrate", $NotFound) If $IniVersion = $NotFound Then _MyError() EndIf $SpeedLimit = IniRead($FullIniPath, "ProgramOptions", "SpeedLimit", $NotFound) If $IniVersion = $NotFound Then _MyError() EndIf $ShowSpeed = IniRead($FullIniPath, "ProgramOptions", "ShowSpeed", $NotFound) If $IniVersion = $NotFound Then _MyError() EndIf $ClearOnTop = IniRead($FullIniPath, "ProgramOptions", "ClearOnTop", $NotFound) If $IniVersion = $NotFound Then _MyError() EndIf $RunPlates = IniRead($FullIniPath, "ProgramOptions", "RunPlates", $NotFound) If $IniVersion = $NotFound Then _MyError() EndIf $Result = IniRead($FullIniPath, "ProgramOptions", "Block", $NotFound) If $IniVersion = $NotFound Then _MyError() EndIf $BlockMouse = True Select Case $Result = "None" $BlockOption = 0 $BlockMouse = False Case $Result = "Both" $BlockOption = 1 Case $Result = "Mouse" $BlockOption = 2 Case $Result = "Keyboard" $BlockOption = 3 $BlockMouse = False Case Else $BlockOption = 0 EndSelect $LogDetail = IniRead($FullIniPath, "LogOptions", "LogDetail", $NotFound) If $IniVersion = $NotFound Then _MyError() EndIf $LogFile = IniRead($FullIniPath, "LogOptions", "LogFile", $NotFound) If $IniVersion = $NotFound Then _MyError() EndIf $Index = 1 While 1 $IniFileName[$Index] = IniRead($FullIniPath, "Files", "File" & $Index, $NotFound) If $IniFileName[$Index] = $NotFound Then ExitLoop EndIf $Index += 1 WEnd $IniFiles = $Index - 1 $Index = 1 While 1 $IniPriority[$Index] = IniRead($FullIniPath, "WindowPriorties", "WindowPriority" & $Index, $NotFound) If $IniPriority[$Index] = $NotFound Then ExitLoop EndIf $Index += 1 WEnd $IniPriorities = $Index - 1 $Index = 1 While 1 $IniMaximize[$Index] = IniRead($FullIniPath, "WindowPriorties", "WindowMaximize" & $Index, $NotFound) If $IniMaximize[$Index] = $NotFound Then ExitLoop EndIf $Index += 1 WEnd If $LogIt = False Then Return EndIf WriteLog(" Ini Path: " & $FullIniPath) WriteLog(" Program: " & $IniProgramGroup) WriteLog(" Version: " & $IniVersion) WriteLog(" Port: " & $CommPort) WriteLog(" Baudrate: " & $BaudRate) WriteLog("SpeedLimit: " & $SpeedLimit) WriteLog(" ShowSpeed: " & $ShowSpeed) WriteLog("ClearOnTop: " & $ClearOnTop) WriteLog(" RunPlates: " & $RunPlates) WriteLog(" Block: " & $AlphaBlock[$BlockOption]) WriteLog(" LogDetail: " & $LogDetail) WriteLog(" LogFile: " & $LogFile) WriteLog("Priorities: " & $IniPriorities) If $IniPriorities >= 1 Then For $Index = 1 To $IniPriorities WriteLog("Priority " & $Index & ": " & $IniPriority[$Index]) WriteLog("Maximize " & $Index & ": " & $IniMaximize[$Index]) Next EndIf EndFunc Func MyCopyProgressOn($Title, $SFileName, $DFileName, $FileSize, $Operation) Local $DisplayName = "" $DisplayName = "Source: " & StringLower($SFileName) ProgressOn($Title, $DisplayName, "0 of " & _StringAddThousandsSepEx($FileSize) & " bytes " & $Operation & " (0%)") EndFunc Func MyCopyProgressSet($ProgressBytes, $FileSize, $Operation) Local $Percent = 0 $Percent = Round((($ProgressBytes / $FileSize) * 100), 0) If $Percent >= 100 Then $Percent = 99 $ProgressBytes = $FileSize - 1 EndIf ProgressSet($Percent, _StringAddThousandsSepEx($ProgressBytes) & " of " & _StringAddThousandsSepEx($FileSize) & " bytes " & $Operation & " (" & $Percent & "%)") Sleep(1) EndFunc Func MyCopyProgressOff() ProgressSet(100 , "Done") Sleep(500) ProgressOff() EndFunc Func MyError() Beep() MsgBox(0, $ErrorTitle, $ErrorMessage) If $IsErrorFatal = True Then Exit EndIf EndFunc Func MyProgressCopy($FullSRC, $FullDST) Dim $OptEnv = "", $OptVar = "", $size = 0, $count = 0, $timer = 0, $progress = 0, $in = 0, $out = 0 Local $Bin, $Chunk, $ProgTitle $ErrorTitle = "Error Copying File" $ErrorMessage = $FullSRC $IsErrorFatal = True ; Turn off expanded environment or variables, can cause problems for binary read $OptEnv = Opt("ExpandEnvStrings", 0) $OptVar = Opt("ExpandVarStrings", 0) ; Get size of file to determine remaining $Size = FileGetSize($FullSRC) If $Size = 0 Then MyError() EndIf ; Set up initial variables $Count = 0 ;keep count of bytes copied $Chunk = 102400 ;amount of data to copy at a time (bytes) (10kB) $Progtitle = "Copying File ..." ;title of progress bar window $Timer = TimerInit() ;initialize timer to keep track of update frequency ; Show progress bar MyCopyProgressOn("Copying File ...", $FullSRC, $FullDST, $size, "copied") ; Open input and output files (exit if error) $In = FileOpen($FullSRC, 4) If @error <> 0 Then MyError() EndIf $Out = FileOpen($FullDST, 2) If @error = -1 Then FileClose($In) MyError() EndIf ; Start reading input $Bin = FileRead($In, $Chunk) While @error = 0 ; Write chunk of data, keep trying for up to 10 seconds if failed Do FileWrite($Out, $Bin) Until (@error = 0) Or (TimerDiff($timer) > 10000) If @error <> 0 Then FileClose($In) FileClose($Out) MyError() EndIf ; Update copy counter $Count = $Count + $Chunk ; Update progress as specified MyCopyProgressSet($Count, $Size, "copied") $timer = TimerInit() ; get chunk of data $bin = FileRead($In, $Chunk) WEnd FileClose($In) FileClose($Out) MyCopyProgressOff() ; Reset expanded environment or variables Opt("ExpandEnvStrings", $OptEnv) Opt("ExpandVarStrings", $OptVar) EndFunc Func WaitWithProgress($Caption, $Seconds) ProgressOn($Caption & ". Please wait ...", "") Local $Loops = 0, $Delay = 0, $Percent = 0 $Loops = Round(($Seconds * 2.0),0) $Delay = Round ((($Seconds / $Loops) * 1000), 0) For $I = 1 to $Loops $Percent = (($I / $Loops) * 100) ProgressSet($Percent) Sleep($Delay) Next ProgressOff() EndFunc Func TurnOffOnTop() Local $Index = 0, $Result = 0, $WindowList, $iExStyles = 0, $Candidate = 0 $WindowList = WinList() For $Index = 1 to $WindowList[0][0] $iExStyles = _WinAPI_GetWindowLong($WindowList[$Index][1],$GWL_EXSTYLE) $Candidate = ($WindowList[$Index][0] <> "") And (IsWindowVisible($WindowList[$Index][1])) $Candidate = $Candidate And (BitAND($iExStyles,$WS_EX_TOPMOST)) $Candidate = $Candidate And (StringLeft($WindowList[$Index][0], $LenSpeedCursor) <> $SpeedCursor) If $Candidate = 1 Then $Result = WinSetOnTop($WindowList[$Index][1], "", 0) WriteLog($WindowList[$Index][0] & " topmost set was: " & $SFResult[$Result]) EndIf Next EndFunc Func IsWindowVisible($WindowHandle) If BitAnd( WinGetState($WindowHandle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc My Archangel.ini file [Version] ProgramGroup=Archangel VersionNumber=1.00 [Communication] Port=35 Baudrate=9600 [ProgramOptions] SpeedLimit=25 ShowSpeed=No ClearOnTop=Yes RunPlates=No Block=None [LogOptions] LogDetail=No LogFile=Archangel.log [Files] File1=Archangel.exe File2=sdx.dll File3=Green.ico File4=Red.ico [WindowPriorties] WindowPriority1=Spillman Mobile - WindowMaximize1=Yes
    1 point
×
×
  • Create New...