Jump to content

MetroGUI UDF v5.1 - Windows 10 style buttons, toggles, radios, menu etc.


Recommended Posts

16 hours ago, BBs19 said:

1. Yes this seems to be the case with all WS_POPUP windows. I haven't noticed this before. I will consider creating the non resizable GUI the same way like the the resizable one (preventing the borders from being drawn). However im not sure how this will impact compatibility, I still haven't tested my UDF on all Windows versions. The WS_POPUP version is more reliable than the borderless GUI version.

2. The GDIPlus functions work with ARGB colors. example: "0xFF000000". So the usual RGB hex colors of the Autoit functions don't work here anyways. I can add a workaround to make it work with hex colors, i just didn't see any need for it.

Understood, makes sense.

Now, can you please hint me how to modify the button creation function to add a picture? I tried but it simply can't draw the picture:

  

    ;Add frame
    _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor)


    ;Add Picture
    $hImage1   = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\win7.png")
    ; Draw PNG image
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND(GetCurrentGUI())
    _GDIPlus_GraphicsDrawImageRect($hGraphic,$hImage1,10,10,200,200)

    ;Release created objects
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($Brush_BTN_FontColor)
    _GDIPlus_BrushDispose($Brush_BTN_FontColorDis)
    _GDIPlus_PenDispose($Pen_BTN_FrameHoverColor)

 

Thanks!

Edited by KarlosTHG
Link to post
Share on other sites
  • Replies 280
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Features: Create modern looking borderless and resizable GUIs with control buttons (Close,Maximize/Restore,Minimize, Fullscreen, Menu) True borderless, resizeable GUI with full support fo

I know I disappointed some of you guys with this version as you were waiting for the requested features like Sliders, InputBox, Support for tabbing through controls and other stuff. I spent a lot of t

Version 4.3 - Changelog - 13.07.2016 Bugfixes: Fixed a bug where the fullscreen button was misplaced on different DPI sizes. Fixed a bug where the maximized window was not properly o

Posted Images

Is it possible to use your UDF in conjunction with GUIonEventMode 1?

Tryed to get it to work for several hours but sadly to no avail, didn't manage to get any functionality besides the mouseover/hover :(.
Is there something really obvious I'm missing? I did tons over tons of reading and simply can't find the reason its not working.

I would really appreciate it if you could take a short look at it to clarify for me if its possible or not.

gui.au3

Edited by Mentis
Link to post
Share on other sites
On 6.7.2016 at 0:45 PM, RWBaker said:

Running Version: MetroUDF-V4.0.1 with Windows 10

The attached file defines and uses two radio groups.  Group 1 works fine, Group 2 does not work correctly.

Could you look into this?

Thanks,

RWBaker

Radio Demo.au3

Oh sh**t. Forgot to assign the radio group variable correctly while creating the radio. I will upload a fixed version with some other bug fixes this week. Thanks for reporting.

 

 

On 30.6.2016 at 4:18 PM, KarlosTHG said:

Understood, makes sense.

Now, can you please hint me how to modify the button creation function to add a picture? I tried but it simply can't draw the picture:

  

    ;Add frame
    _GDIPlus_GraphicsDrawRect($Button_Graphic2[0], 0, 0, $Width, $Height, $Pen_BTN_FrameHoverColor)


    ;Add Picture
    $hImage1   = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\win7.png")
    ; Draw PNG image
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND(GetCurrentGUI())
    _GDIPlus_GraphicsDrawImageRect($hGraphic,$hImage1,10,10,200,200)

    ;Release created objects
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($Brush_BTN_FontColor)
    _GDIPlus_BrushDispose($Brush_BTN_FontColorDis)
    _GDIPlus_PenDispose($Pen_BTN_FrameHoverColor)

 

Thanks!

I don't know it just by looking at it, i would need to check and test myself. I am really not experienced with GDI+. I have not much time atm. I will tell you later when when im working on the UDF.

 

 

16 hours ago, Mentis said:

Is it possible to use your UDF in conjunction with GUIonEventMode 1?

Tryed to get it to work for several hours but sadly to no avail, didn't manage to get any functionality besides the mouseover/hover :(.
Is there something really obvious I'm missing? I did tons over tons of reading and simply can't find the reason its not working.

I would really appreciate it if you could take a short look at it to clarify for me if its possible or not.

gui.au3

It works partly, but it isn't fully compatible with it. There will be some incompatibilities.

The reason you can't click any buttons is, because you used "GUICtrlSetOnEvent(-1,"_button")". -1 is AutoIt internal and works only with the last created control. In the UDF, the main Autoit control (GUICtrlCreatePic) is created at the beginning and is probably overwritten by something else before the function ends. I will try to move that to the end of the functions, as it seems to be a better option. 

But as I said, there will/might be problems with guictrlsetonevent as it will interfere with many other internal functions.

Link to post
Share on other sites

Thanks for your quickly reply and really clear explanation what exactly went wrong.
 

Amazing UDF but sadly my software depends on GUIonEventMode 1, theres no realistic way to get arround that.
I'll definitely keep my eyes on your thread and wait, it would be definitely superawesome if you figured something out
My guis "only" requirements in order to establish a basic functionality are  metrobuttons that call a func(), metro Checkebox, metro messagebox, , GUICtrlSetData and GUICtrlSetOnEvent

I'd really love to help and extend your UDF myself, but sadly my skills are not sufficient :( (yet)

Link to post
Share on other sites
On 8.7.2016 at 3:16 PM, PratikV said:

Hi BBs19, Thank you for the MetroUI. 

I am in the same boat as of Mentis and would like to know how can i use GUIOneventMode Function.

Thank you very much for the wonderful work.

Yes, give me a few days. I have already fixed many bugs and will try to add compatibility for GUIOnEventMode in the next step.

Link to post
Share on other sites
7 hours ago, hawk63 said:

Thank you for this great UDF.

Just one question : haw can i change the text of the toggle when i click on it (like windows 10) ? In order to display 'enabled' / 'disabled'.

You couldn't do that before, but now you can, see new version :) 

 

On 8.7.2016 at 3:16 PM, PratikV said:

Hi BBs19, Thank you for the MetroUI. 

I am in the same boat as of Mentis and would like to know how can i use GUIOneventMode Function.

Thank you very much for the wonderful work.

Sorry dude, GUIOnEventMode just won't work fully with this UDF. This UDF is just too big.. There are just too many workarounds implemented to make everything work as it does at the moment.

I had it running almost, but the metro MsgBox and Menu just won't work that way. Anything that stops the script when waiting for user input breaks the compatibility for OnEvent.  I ran out of ideas for new workarounds...

You can use it with one GUI though, if you don't use metro MsgBox, Menu or a second GUI..

Edited by BBs19
Link to post
Share on other sites

Version 4.3 - Changelog - 13.07.2016

Bugfixes:

  • Fixed a bug where the fullscreen button was misplaced on different DPI sizes.
  • Fixed a bug where the maximized window was not properly on the top edge after using the fullscreen mode.
  • Fixed a bug where the checkbox groups were not assigned properly.
  • Fixed the bug that using "-1" didn't point to the handle of the created metro control (buttons, checkboxes etc.)
  • Fixed a bug where the default window control buttons appeared after minimizing from the taskbar and using older Windows versions.
  • Fixed a bug where MustDeclareVars option couldn't be used without errors.
  • Fixed a bug that caused problems when using multiple metro GUIs with fullscreen + resizing option.

Improvements:

  • Dark themes are slightly brighter now. They were too dark on many screens.
  • Creating a GUI without drag&resize is now also created as a true borderless GUI instead of using $WS_POPUP. (To support minimizing from the taskbar)
  • When working with multiple metro GUIs, you no longer need to use "_GUI_DragAndResizeUpdate" after switching GUIs. (_GUI_DragAndResizeUpdate won't work anymore)
  • You can now pass color settings for the metro functions in hex and don't have to pass it as string.

New features:

  • Added on/off toggles. This allows you to create a toggle with two different texts like "enabled/disabled".
  • Added timeout option for metro MsgBox.
  • Added font options for the menu buttons.
  • Added new _Metro_SetGUIOption which allows to set options like drag, resize, min width and min height seperately for a GUI.

 

Download: 

 

Link to post
Share on other sites
  • 3 weeks later...

I've been having a play about but i cant stop it from going full screen, can anyone help me?.

My script is:

#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so /rm /pe
#AutoIt3Wrapper_Res_HiDpi=y
#TrayIcon
#include "MetroGUI-UDF\MetroGUI_UDF.au3"

_SetTheme("DarkBlueV2") ;See MetroThemes.au3 for selectable themes or to add more
_Metro_EnableHighDPIScaling()

$Form1 = _Metro_CreateGUI("Example", 350, 350, -1, -1)
$Control_Buttons = _Metro_AddControlButtons(True, False, False, False, True) ;CloseBtn = True, MaximizeBtn = True, MinimizeBtn = True, FullscreenBtn = True, MenuBtn = True

;Set variables for the handles of the GUI-Control buttons. (Above function always returns an array this size and in this order, no matter which buttons are selected.
$GUI_CLOSE_BUTTON = $Control_Buttons[0]
$GUI_MAXIMIZE_BUTTON = $Control_Buttons[1]
$GUI_RESTORE_BUTTON = $Control_Buttons[2]
$GUI_MINIMIZE_BUTTON = $Control_Buttons[3]
$GUI_FULLSCREEN_BUTTON = $Control_Buttons[4]
$GUI_FSRestore_BUTTON = $Control_Buttons[5]
$GUI_MENU_BUTTON = $Control_Buttons[6]
;======================================================================================================================================================================

;Create  Buttons
$Button1 = _Metro_CreateButton("Button Style 1", 105, 245, 130, 40)
$Button2 = _Metro_CreateButtonEx("Button Style 2", 255, 245, 130, 40)

;Create an Array containing menu button names
Dim $MenuButtonsArray[4] = ["a", "b", "", "Exit"]

GUISetState(@SW_SHOW)

While 1
    _Metro_HoverCheck_Loop($Form1) ;This hover check has to be added to the main While loop, otherwise the hover effects won't work.
    $nMsg = GUIGetMsg()
    Switch $nMsg
        ;=========================================Control-Buttons===========================================
        Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON
            _Metro_GUIDelete($Form1) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs!
            Exit
        Case $GUI_MAXIMIZE_BUTTON
            GUISetState(@SW_MAXIMIZE)
        Case $GUI_RESTORE_BUTTON
            GUISetState(@SW_RESTORE)
        Case $GUI_MINIMIZE_BUTTON
            GUISetState(@SW_MINIMIZE)
        Case $GUI_FULLSCREEN_BUTTON, $GUI_FSRestore_BUTTON
            _Metro_FullscreenToggle($Form1, $Control_Buttons)
            ;===================================================================================================
        Case $GUI_MENU_BUTTON
            Local $MenuSelect = _Metro_MenuStart($Form1, $GUI_MENU_BUTTON, 150, $MenuButtonsArray, "Segoe UI", 9, 0) ; Opens the metro Menu. See decleration of $MenuButtonsArray above.
            Switch $MenuSelect ;Above function returns the index number of the selected button from the provided buttons array.
                Case "0"
                    ConsoleWrite("Returned 0 = Settings button clicked." & @CRLF)
                Case "1"
                    ConsoleWrite("Returned 1 = About button clicked." & @CRLF)
                Case "2"
                    ConsoleWrite("Returned 2 = Contact button clicked." & @CRLF)
                Case "3"
                    ConsoleWrite("Returned 3 = Exit button clicked." & @CRLF)
                    _Metro_GUIDelete($Form1)
                    Exit
            EndSwitch
        Case $Button2
            _GUIDisable($Form1, 0, 30) ;For better visibility of the MsgBox on top of the first GUI.
            _Metro_MsgBox(0, "Metro MsgBox Example", "Button 2 clicked. (Button with 3 secs timeout)", 400, 11, $Form1, 3) ; with 3 secs timeout
            _GUIDisable($Form1)
        Case $Button1
            _GUIDisable($Form1, 0, 30)

            Local $Select_YesNo = _Metro_MsgBox(4, "Metro MsgBox Example", "Select yes to create a second GUI.", 350, 11, $Form1)
            If $Select_YesNo = "Yes" Then _SecondGUI()
            _GUIDisable($Form1)
    EndSwitch
WEnd


Func _SecondGUI()
    Local $Form2 = _Metro_CreateGUI("Example2", 600, 400, -1, -1, True)

    ;Add control buttons
    Local $Control_Buttons_2 = _Metro_AddControlButtons(True, True, True, True)

    ;Set variables for control buttons
    Local $GUI_CLOSE_BUTTON = $Control_Buttons_2[0]
    Local $GUI_MAXIMIZE_BUTTON = $Control_Buttons_2[1]
    Local $GUI_RESTORE_BUTTON = $Control_Buttons_2[2]
    Local $GUI_MINIMIZE_BUTTON = $Control_Buttons_2[3]
    Local $GUI_FULLSCREEN_BUTTON = $Control_Buttons_2[4]
    Local $GUI_FSRestore_BUTTON = $Control_Buttons_2[5]
    Local $Button1 = _Metro_CreateButton("Close", 250, 340, 100, 40)
    GUICtrlSetResizing($Button1, 768 + 8)
    GUISetState(@SW_SHOW)

    While 1
        _Metro_HoverCheck_Loop($Form2) ;Add hover check in loop
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON, $Button1
                _Metro_GUIDelete($Form2) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs!
                Return 0
            Case $GUI_MAXIMIZE_BUTTON
                GUISetState(@SW_MAXIMIZE)
            Case $GUI_RESTORE_BUTTON
                GUISetState(@SW_RESTORE)
            Case $GUI_MINIMIZE_BUTTON
                GUISetState(@SW_MINIMIZE)
            Case $GUI_FULLSCREEN_BUTTON, $GUI_FSRestore_BUTTON
                _Metro_FullscreenToggle($Form2, $Control_Buttons_2)
        EndSwitch
    WEnd
EndFunc   ;==>_SecondGUI

 

Link to post
Share on other sites

Just found this a couple days ago, I really like it!

I have an example (heavily modified, though the display is close to the same, minus the progress bar and secondary window).

This example is a great way to solve the inability to use GUIOnEventMode, and a great way to add more constantly updating code (like Network games, etc) in the future.

This example has two scripts: Main.au3, and App.au3, where App.au3 is essentially the GUI code.

Main.au3 has Three functions that get called automagicly for convenience and conservation sake:

-OnStart(), which is invoked after the code is ready to roll

-OnUpdate($FrameTime), which is invoked $UPDATESPERSECOND (a global constant) * Second, and supplies the time between frames, incase you need time sensitive code to adjust for lost time.

-OnPreStop(), which is the function where you would put clean up code, all OnUpdate code is still valid in this function.

-DoStop(), which causes the program to request stop immediately, obviously.

App.au3 is the modified GUI code. Main.au3:

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.2
 Author:         Jon/~RepComm

 Script Function:
    Main (Runs update clock, and exposes functions for application use)

#ce ----------------------------------------------------------------------------

#include "App.au3"

Opt ("MustDeclareVars", 1)

Global Const $UPDATESPERSECOND = 30
Global $STATE = False ; Set to False when exiting from this script (Normally we just check _App_GetState() from App.au3)

#Region =======Internal========
Init ()

Func Init() ; Called to initialize everything (Entry point)
    $STATE = True
    ;Global Const $UPDATESPERSECOND = 30
    Global Const $TimeBetweenUpdates = 1000 / $UPDATESPERSECOND ; 1000 Millis = 1 second
    Global $IsRunning = true
    Global $oTimer = TimerInit()
    Global $nNowTime = 0
    Global $nLastTime = 0
    Global $nUpdateTime ; In OnUpdate(), this value can be used to get time the last frame took
    Global $nNowThenDifference ; Every frame cycle, this equals now - last
    OnStart()
    CauseUpdates()
EndFunc

Func CauseUpdates () ; Called to start the clock-invoked OnUpdate function
    While ($IsRunning) ; Constantly loop
        $nNowTime = TimerDiff($oTimer) ; Get difference from program startup to now
        $nNowThenDifference = $nNowTime - $nLastTime ; Difference from last time we updated to now
        If ($nNowThenDifference >= $TimeBetweenUpdates) Then ; If sufficient time has passed, Update
            If (_App_GetState() == False Or $STATE == False) Then ; Check if App.au3's code wants to stop
                Stop() ; Cause program to stop completely
            EndIf
            $nLastTime = $nNowTime ; Future use of vars
            $nUpdateTime = $nNowThenDifference ; $nUpdateTime is always the amount of time it took between frames (Second/Updates), NowThenDiff can potentially be any time inbetween
            OnUpdate($nUpdateTime) ; Invoke Update function $UPDATESPERSECOND * Second, supplying the time we took between frames (Useful for physics or time relative calculations)
        EndIf
    WEnd
    ; This function ends when the program ends
EndFunc

Func Stop () ; Call to stop program
    OnPreStop() ; All OnUpdate code is still valid for use in this function (Until IsRunning = False)
    $IsRunning = False ; Stops OnUpdate() From happening
    Exit ; Final stop
EndFunc
#EndRegion

Func OnStart() ; Put initializing or startup code here
    ; Called after internal is already setup and ready to roll
    _App_Start() ; Tell App.au3's code to init its GUI 'n stuff
EndFunc

Func OnUpdate ($FrameTime) ; You can put constantly updating code here
    ; This function is called $UPDATESPERSECOND * Second
    ; $FrameTime is the time between this update, and the last one, in seconds. (Incase you have time-sensitive calculations to do)
    _App_Update($FrameTime) ; Update our GUI code in App.au3
EndFunc

Func OnPreStop () ; You can put cleanup code here
    ; This function is called before the program actually does any cleaning, so all update code is still valid here
    _App_Stop()
EndFunc

Func DoStop() ; Call this function to request app stop immediately
    $STATE = False
EndFunc

App.au3:

#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so /rm /pe
#AutoIt3Wrapper_Res_HiDpi=y

#NoTrayIcon
#include "MetroGUI-UDF\MetroGUI_UDF.au3"

Global $STATE = False
Global $nMsg

Func _App_Start()
    $STATE = True
    _SetTheme("DarkAmber")
    _Metro_EnableHighDPIScaling()

    Global $hGUIMain = _Metro_CreateGUI("App", 720, 420, -1, -1, True)
    Global $Control_Buttons = _Metro_AddControlButtons(True, True, True, True, True) ;CloseBtn = True, MaximizeBtn = True, MinimizeBtn = True, FullscreenBtn = True, MenuBtn = True

    Global $GUI_CLOSE_BUTTON = $Control_Buttons[0]
    Global $GUI_MAXIMIZE_BUTTON = $Control_Buttons[1]
    Global $GUI_RESTORE_BUTTON = $Control_Buttons[2]
    Global $GUI_MINIMIZE_BUTTON = $Control_Buttons[3]
    Global $GUI_FULLSCREEN_BUTTON = $Control_Buttons[4]
    Global $GUI_FSRestore_BUTTON = $Control_Buttons[5]
    Global $GUI_MENU_BUTTON = $Control_Buttons[6]

    Global $Button1 = _Metro_CreateButton("Button Style 1", 105, 245, 130, 40)
    Global $Button2 = _Metro_CreateButtonEx("Button Style 2", 255, 245, 130, 40)

    Global $Checkbox1 = _Metro_CreateCheckbox("Checkbox 1", 30, 70, 125, 30)
    Global $Checkbox2 = _Metro_CreateCheckboxEx("Checkbox 2", 30, 107, 125, 30)
    _Metro_CheckboxCheck($Checkbox1)
    _Metro_CheckboxCheck($Checkbox2)

    Global $Radio1 = _Metro_CreateRadio("1", "Radio 1", 180, 70, 100, 30)
    Global $Radio2 = _Metro_CreateRadio("1", "Radio 2", 180, 110, 100, 30)
    _Metro_RadioCheck("1", $Radio1)

    Global $Toggle1 = _Metro_CreateToggle("Toggle 1", 320, 70, 130, 30)
    Global $Toggle2 = _Metro_CreateToggleEx("Toggle 2", 322, 107, 128, 30)
    Global $Toggle3 = _Metro_CreateOnOffToggle("Enabled", "Disabled", 320, 144, 130, 30)

    ;Create an Array containing menu button names
    Global $MenuButtonsArray[4] = ["Settings", "About", "Contact", "Exit"]

    GUICtrlSetResizing($Button1, 768 + 8)
    GUICtrlSetResizing($Button2, 768 + 8)
    GUICtrlSetResizing($Checkbox1, 768 + 2 + 32)
    GUICtrlSetResizing($Checkbox2, 768 + 2 + 32)
    GUICtrlSetResizing($Radio1, 768 + 2 + 32)
    GUICtrlSetResizing($Radio2, 768 + 2 + 32)
    GUICtrlSetResizing($Toggle1, 768 + 2 + 32)
    GUICtrlSetResizing($Toggle2, 768 + 2 + 32)
    GUICtrlSetResizing($Toggle3, 768 + 2 + 32)

    GUISetState(@SW_SHOW)
EndFunc

Func _App_Update ($FrameTime) ; Most of this code is staying the same, because _App_Update is in a constant loop (Main.au3's OnUpdate() function)
    _Metro_HoverCheck_Loop($hGUIMain) ;  This was moved from a bland while() statement
    $nMsg = GUIGetMsg()
    Switch $nMsg
        ;=========================================Control-Buttons===========================================
        Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON
            _Metro_GUIDelete($hGUIMain) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs!
            _App_Stop()
        Case $GUI_MAXIMIZE_BUTTON
            GUISetState(@SW_MAXIMIZE)
        Case $GUI_RESTORE_BUTTON
            GUISetState(@SW_RESTORE)
        Case $GUI_MINIMIZE_BUTTON
            GUISetState(@SW_MINIMIZE)
        Case $GUI_FULLSCREEN_BUTTON, $GUI_FSRestore_BUTTON
            _Metro_FullscreenToggle($hGUIMain, $Control_Buttons)
            ;===================================================================================================
        Case $GUI_MENU_BUTTON
            Local $MenuSelect = _Metro_MenuStart($hGUIMain, $GUI_MENU_BUTTON, 150, $MenuButtonsArray, "Segoe UI", 9, 0) ; Opens the metro Menu. See decleration of $MenuButtonsArray above.
            Switch $MenuSelect ;Above function returns the index number of the selected button from the provided buttons array.
                Case "0"
                    ConsoleWrite("Returned 0 = Settings button clicked." & @CRLF)
                Case "1"
                    ConsoleWrite("Returned 1 = About button clicked." & @CRLF)
                Case "2"
                    ConsoleWrite("Returned 2 = Contact button clicked." & @CRLF)
                Case "3"
                    ConsoleWrite("Returned 3 = Exit button clicked." & @CRLF)
                    _Metro_GUIDelete($hGUIMain) ; This can stay here, or be moved to a cleanup function (fired by Main.au3's OnPreStop() function)
                    _App_Stop()
            EndSwitch
        Case $Button2
            _GUIDisable($hGUIMain, 0, 30) ;For better visibility of the MsgBox on top of the first GUI.
            _Metro_MsgBox(0, "Metro MsgBox Example", "Button 2 clicked. (Button with 3 secs timeout)", 400, 11, $hGUIMain, 3) ; with 3 secs timeout
            _GUIDisable($hGUIMain)
        Case $Toggle1
            If _Metro_ToggleIsChecked($Toggle1) Then
                _Metro_ToggleUnCheck($Toggle1)
                ConsoleWrite("Toggle unchecked!" & @CRLF)
            Else
                _Metro_ToggleCheck($Toggle1)
                ConsoleWrite("Toggle checked!" & @CRLF)
            EndIf
        Case $Toggle2
            If _Metro_ToggleIsChecked($Toggle2) Then
                _Metro_ToggleUnCheck($Toggle2)
                ConsoleWrite("Toggle unchecked!" & @CRLF)
            Else
                _Metro_ToggleCheck($Toggle2)
                ConsoleWrite("Toggle checked!" & @CRLF)
            EndIf
        Case $Toggle3
            If _Metro_ToggleIsChecked($Toggle3) Then
                _Metro_ToggleUnCheck($Toggle3)
                ConsoleWrite("Disabled!" & @CRLF)
            Else
                _Metro_ToggleCheck($Toggle3)
                ConsoleWrite("Enabled!" & @CRLF)
            EndIf
        Case $Checkbox1
            If _Metro_CheckboxIsChecked($Checkbox1) Then
                _Metro_CheckboxUnCheck($Checkbox1)
                ConsoleWrite("Checkbox unchecked!" & @CRLF)
            Else
                _Metro_CheckboxCheck($Checkbox1)
                ConsoleWrite("Checkbox checked!" & @CRLF)
            EndIf
        Case $Checkbox2
            If _Metro_CheckboxIsChecked($Checkbox2) Then
                _Metro_CheckboxUnCheck($Checkbox2)
                ConsoleWrite("Checkbox unchecked!" & @CRLF)
            Else
                _Metro_CheckboxCheck($Checkbox2)
                ConsoleWrite("Checkbox checked!" & @CRLF)
            EndIf
        Case $Radio1
            _Metro_RadioCheck(1, $Radio1)
            ConsoleWrite("Radio 1 selected!" & @CRLF)
        Case $Radio2
            _Metro_RadioCheck(1, $Radio2)
            ConsoleWrite("Radio 2 selected = " & _Metro_RadioIsChecked(1, $Radio2) & @CRLF)
    EndSwitch
EndFunc

Func _App_Stop () ; Call this to tell Main.au3 to stop the program
    $STATE = False
EndFunc

Func _App_GetState () ; Main.au3 calls this in the update functions to see if we are still doing good
    Return $STATE
EndFunc

-- A side note, I was unable to change all the Theme for the window when using _SetTheme after initializations, etc. But the menu does change background color. A nice feature to look into (and I might just do this myself later), would be the ability to apply themes at runtime (since GDI plus doesn't care when you change brush colors, etc). You could just have a global variable that tells when SetTheme is used, and in the update loop, check it, and apply colors to the brushes that are used to draw the gui/controls, then draw them.

Edited by RepublicCommando
Spelling, no reason to double post, and I can't count..
Link to post
Share on other sites
On 29.7.2016 at 7:33 PM, cookiemonster said:

I've been having a play about but i cant stop it from going full screen, can anyone help me?.

My script is:

 

 

On 29.7.2016 at 9:11 PM, nobbitry said:

Hi cookiemonster, 

its an error in the UDF. You can see it if you use:

$Control_Buttons = _Metro_AddControlButtons(True, True, True, True, True)

I didn't search for the error, but it only works if you set everything 'True'.

Regards

 

It is no bug. If you remove the creation of fullscreen button or other control buttons, then u also have to remove them from the switch case in the main while loop of the example :)

Link to post
Share on other sites

my trouble resizing Progress

http://prntscr.com/c2jsc1

Spoiler
#include "MetroGUI-UDF\MetroGUI_UDF.au3"
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so /rm /pe
#AutoIt3Wrapper_Res_HiDpi=y
_SetTheme("DarkBlue")
$Form1 = _Metro_CreateGUI("Example", 440, 500, -1, -1, True)
$Control_Buttons = _Metro_AddControlButtons(True, True, True, True, True) ;CloseBtn = True, MaximizeBtn = True, MinimizeBtn = True, FullscreenBtn = True, MenuBtn = True
$GUI_CLOSE_BUTTON = $Control_Buttons[0]
$GUI_MAXIMIZE_BUTTON = $Control_Buttons[1]
$GUI_RESTORE_BUTTON = $Control_Buttons[2]
$GUI_MINIMIZE_BUTTON = $Control_Buttons[3]
$GUI_FULLSCREEN_BUTTON = $Control_Buttons[4]
$GUI_FSRestore_BUTTON = $Control_Buttons[5]
$GUI_MENU_BUTTON = $Control_Buttons[6]

$Edit1 = GUICtrlCreateEdit("", 24, 82, 185, 217)
GUICtrlSetData(-1, "Edit1")
$Edit2 = GUICtrlCreateEdit("", 232, 82, 185, 217)
GUICtrlSetData(-1, "Edit2")
$Button1 = _Metro_CreateButton("Button 1", 72, 314, 91, 33)
$Button2 = _Metro_CreateButton("Button 2", 280, 314, 91, 33)

$Toggle1 = _Metro_CreateToggle("Alarm", 72, 355, 100, 30)
GUICtrlSetTip($Toggle1 , "On/Off")

$Checkbox1 = _Metro_CreateCheckbox("Check", 56, 32, 97, 30)
_Metro_CheckboxCheck($Checkbox1)
$Input1 = GUICtrlCreateInput("Input1", 24, 394, 393, 21)
$Progress1 = _Metro_CreateProgress(24, 434, 390, 33)
$Label1 = GUICtrlCreateLabel("Autoit", 296, 52, 64, 16)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)

Dim $MenuButtonsArray[4] = ["Settings", "About", "Contact", "Exit"]

GUICtrlSetResizing($Button1, 768 + 8)
GUICtrlSetResizing($Button2, 768 + 8)
GUICtrlSetResizing($Checkbox1, 768 + 2 + 32)
GUICtrlSetResizing($Progress1[0], 768 + 2 + 32)

GUISetState(@SW_SHOW)

While 1
    _Metro_HoverCheck_Loop($Form1)
    Sleep(10)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON
            _Metro_GUIDelete($Form1) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs!
            Exit
        Case $GUI_MAXIMIZE_BUTTON
            GUISetState(@SW_MAXIMIZE)
        Case $GUI_RESTORE_BUTTON
            GUISetState(@SW_RESTORE)
        Case $GUI_MINIMIZE_BUTTON
            GUISetState(@SW_MINIMIZE)
        Case $GUI_FULLSCREEN_BUTTON, $GUI_FSRestore_BUTTON
            _Metro_FullscreenToggle($Form1, $Control_Buttons)
    Case $GUI_MENU_BUTTON
            Local $MenuSelect = _Metro_MenuStart($Form1, $GUI_MENU_BUTTON, 150, $MenuButtonsArray, "Segoe UI", 9, 0) ; Opens the metro Menu. See decleration of $MenuButtonsArray above.
            Switch $MenuSelect ;Above function returns the index number of the selected button from the provided buttons array.
                Case "0"
                    ConsoleWrite("Returned 0 = Settings button clicked." & @CRLF)
                Case "1"
                    ConsoleWrite("Returned 1 = About button clicked." & @CRLF)
                Case "2"
                    ConsoleWrite("Returned 2 = Contact button clicked." & @CRLF)
                Case "3"
                    ConsoleWrite("Returned 3 = Exit button clicked." & @CRLF)
                    _Metro_GUIDelete($Form1)
                    Exit
            EndSwitch


        Case $Button1
            _Metro_MsgBox(0, "Metro MsgBox Example", "Button clicked.", 400, 11, $Form1)
For $i = 0 To 85 Step +2
                Sleep(5)
                _Metro_SetProgress($Progress1, $i)
Next

Case $Toggle1
            If _Metro_ToggleIsChecked($Toggle1) Then
                _Metro_ToggleUnCheck($Toggle1)
                ConsoleWrite("Toggle unchecked!" & @CRLF)
            Else
                _Metro_ToggleCheck($Toggle1)
                ConsoleWrite("Toggle checked!" & @CRLF)
            EndIf

            Case $Checkbox1
            If _Metro_CheckboxIsChecked($Checkbox1) Then
                _Metro_CheckboxUnCheck($Checkbox1)
                ConsoleWrite("Checkbox unchecked!" & @CRLF)
            Else
                _Metro_CheckboxCheck($Checkbox1)
                ConsoleWrite("Checkbox checked!" & @CRLF)
            EndIf

    EndSwitch
WEnd

 

 

Link to post
Share on other sites
13 hours ago, youtuber said:

my trouble resizing Progress

http://prntscr.com/c2jsc1

  Hide contents
#include "MetroGUI-UDF\MetroGUI_UDF.au3"
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so /rm /pe
#AutoIt3Wrapper_Res_HiDpi=y
_SetTheme("DarkBlue")
$Form1 = _Metro_CreateGUI("Example", 440, 500, -1, -1, True)
$Control_Buttons = _Metro_AddControlButtons(True, True, True, True, True) ;CloseBtn = True, MaximizeBtn = True, MinimizeBtn = True, FullscreenBtn = True, MenuBtn = True
$GUI_CLOSE_BUTTON = $Control_Buttons[0]
$GUI_MAXIMIZE_BUTTON = $Control_Buttons[1]
$GUI_RESTORE_BUTTON = $Control_Buttons[2]
$GUI_MINIMIZE_BUTTON = $Control_Buttons[3]
$GUI_FULLSCREEN_BUTTON = $Control_Buttons[4]
$GUI_FSRestore_BUTTON = $Control_Buttons[5]
$GUI_MENU_BUTTON = $Control_Buttons[6]

$Edit1 = GUICtrlCreateEdit("", 24, 82, 185, 217)
GUICtrlSetData(-1, "Edit1")
$Edit2 = GUICtrlCreateEdit("", 232, 82, 185, 217)
GUICtrlSetData(-1, "Edit2")
$Button1 = _Metro_CreateButton("Button 1", 72, 314, 91, 33)
$Button2 = _Metro_CreateButton("Button 2", 280, 314, 91, 33)

$Toggle1 = _Metro_CreateToggle("Alarm", 72, 355, 100, 30)
GUICtrlSetTip($Toggle1 , "On/Off")

$Checkbox1 = _Metro_CreateCheckbox("Check", 56, 32, 97, 30)
_Metro_CheckboxCheck($Checkbox1)
$Input1 = GUICtrlCreateInput("Input1", 24, 394, 393, 21)
$Progress1 = _Metro_CreateProgress(24, 434, 390, 33)
$Label1 = GUICtrlCreateLabel("Autoit", 296, 52, 64, 16)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)

Dim $MenuButtonsArray[4] = ["Settings", "About", "Contact", "Exit"]

GUICtrlSetResizing($Button1, 768 + 8)
GUICtrlSetResizing($Button2, 768 + 8)
GUICtrlSetResizing($Checkbox1, 768 + 2 + 32)
GUICtrlSetResizing($Progress1[0], 768 + 2 + 32)

GUISetState(@SW_SHOW)

While 1
    _Metro_HoverCheck_Loop($Form1)
    Sleep(10)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON
            _Metro_GUIDelete($Form1) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs!
            Exit
        Case $GUI_MAXIMIZE_BUTTON
            GUISetState(@SW_MAXIMIZE)
        Case $GUI_RESTORE_BUTTON
            GUISetState(@SW_RESTORE)
        Case $GUI_MINIMIZE_BUTTON
            GUISetState(@SW_MINIMIZE)
        Case $GUI_FULLSCREEN_BUTTON, $GUI_FSRestore_BUTTON
            _Metro_FullscreenToggle($Form1, $Control_Buttons)
    Case $GUI_MENU_BUTTON
            Local $MenuSelect = _Metro_MenuStart($Form1, $GUI_MENU_BUTTON, 150, $MenuButtonsArray, "Segoe UI", 9, 0) ; Opens the metro Menu. See decleration of $MenuButtonsArray above.
            Switch $MenuSelect ;Above function returns the index number of the selected button from the provided buttons array.
                Case "0"
                    ConsoleWrite("Returned 0 = Settings button clicked." & @CRLF)
                Case "1"
                    ConsoleWrite("Returned 1 = About button clicked." & @CRLF)
                Case "2"
                    ConsoleWrite("Returned 2 = Contact button clicked." & @CRLF)
                Case "3"
                    ConsoleWrite("Returned 3 = Exit button clicked." & @CRLF)
                    _Metro_GUIDelete($Form1)
                    Exit
            EndSwitch


        Case $Button1
            _Metro_MsgBox(0, "Metro MsgBox Example", "Button clicked.", 400, 11, $Form1)
For $i = 0 To 85 Step +2
                Sleep(5)
                _Metro_SetProgress($Progress1, $i)
Next

Case $Toggle1
            If _Metro_ToggleIsChecked($Toggle1) Then
                _Metro_ToggleUnCheck($Toggle1)
                ConsoleWrite("Toggle unchecked!" & @CRLF)
            Else
                _Metro_ToggleCheck($Toggle1)
                ConsoleWrite("Toggle checked!" & @CRLF)
            EndIf

            Case $Checkbox1
            If _Metro_CheckboxIsChecked($Checkbox1) Then
                _Metro_CheckboxUnCheck($Checkbox1)
                ConsoleWrite("Checkbox unchecked!" & @CRLF)
            Else
                _Metro_CheckboxCheck($Checkbox1)
                ConsoleWrite("Checkbox checked!" & @CRLF)
            EndIf

    EndSwitch
WEnd

 

 

Set the proper resizing option for the progress: 

GUICtrlSetResizing($Progress1[0],  1)

 

See https://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetResizing.htm

Link to post
Share on other sites
  • 2 weeks later...

Hi,


I am using the MetroStyle-UDF, but i need a combo (pulldown) to fit in the style of the GUI.

I have attached my script to let you show what i mean, also you wil find an example of what i am looking for.
I am looking for a nice font to use in the GUI, can anyone give my a tip?

Hope you can help me.

Forum-Post.zip

Edited by Wingens
Link to post
Share on other sites
  • 4 weeks later...
  • 4 weeks later...

Hi @KillTrot

I suggest to disable the Button and create a new one at that position (click Button 1 to change Button 2):

#NoTrayIcon
#include "MetroGUI-UDF\MetroGUI_UDF.au3"


_SetTheme("DarkGreen")
_Metro_EnableHighDPIScaling()

$Form1 = _Metro_CreateGUI("Example", 500, 300, -1, -1, False)
$Control_Buttons = _Metro_AddControlButtons(True)
$GUI_CLOSE_BUTTON = $Control_Buttons[0]

;Create  Buttons
$Button1 = _Metro_CreateButton("Button Style 1", 105, 245, 130, 40)
$Button2 = _Metro_CreateButtonEx("Button Style 2", 255, 245, 130, 40)

GUISetState(@SW_SHOW)

While 1
    _Metro_HoverCheck_Loop($Form1)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON
            _Metro_GUIDelete($Form1)
            Exit
        Case $Button1 ; <- That's what I mean
            $aPos = ControlGetPos($Form1, "", $Button2)
            _Metro_DisableButton($Button2)
            $Button2 = _Metro_CreateButton("New Button 2", $aPos[0], $aPos[1], $aPos[2], $aPos[3])
        Case $Button2
            MsgBox(0, "", "clicked", 1)
    EndSwitch
WEnd

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By WilliamasKumeliukas
      2021.07.15 News: Project is NOT dead! I am still very devoted into accomplishing this project, I am spending my every bit of energy that is left end of the day (when there is any) on this project and it really does challenge my knowledge in AutoIT language but I won't give up  
       
      Hi,
      I started this project alone in May 2020 as project in my spare time at work, I'm working for a IT company that started opening their services to residential customers few months ago and now my position in the company kind of drifted in the doom and gloom world of repetitive tasks like: Reinstallation + Configuration of Windows 10.
      The procedure is very repetitive and I started feeling like being a robot which is the main reason I started this project.
       
      ==============================FAQ==================================
      1. Q: Do you want this project to be accomplished with the usage of AutoIT ONLY or 3rd party tools / Scripts (BATCH / POWERSHELL / VB) ? A: No, if I cannot find a way using AutoIT to accomplish a task I will move to my Plan B which consist of automating an 3rd party tool to accomplish the affected task until a solution is found. 2. Q: What do I get from helping/collaborating in this project? A: I will personally take the responsability to mention you in the credits of this project. 3. Q: If I have more questions, can I ask? A: Certainly! feel free to ask any questions related to this project! 4. Q: What is the main goal of this project? A: Automating Windows 10 configuration without user interaction needed (as much as possible) ______________________________________________________________________________________________________________________________
      Current progression of the project (more will be added in future)
      « Blue = Info || Yellow = Unfinished/Untested || Purple = Could be better || Green = Done ||Red = Not Yet Started »
      ***Very early Stage ***
      Connect Network Attached Storage(NAS) (Work but missing configuration in GUI - AutoIT only)
      Download & Install up to 600+ softwares (Tested & Working - using 3rd party tool + Powershell)
       Auto prediction of Apps name of text typed inside input (Tested & Working - AutoIT Only)
      Change OEM Informations (Tested & Working -  AutoIT)
      Disable ScreenSaver (Work but require testing AutoIT only)
      Change Computer Name (Work but require testing AutoIT only) 
      Show Computer Information and Smart status on GUI (Tested & Working - AutoIT Only)
      Change .pdf / .pdfxml from Edge to Adobe Reader DC (Tested & Working - using 3rd party tool)
      Change Edge to Google Chrome as Default Browser (Tested & Working - using 3rd party tool)
      Windows Updater (Seems to work but require further testing - AutoIT only)
      Install Office 365 / 2013 + Activation (To Do)
      Add L2TP VPN Configuration in Windows Built-in VPN (To Do)
      Save / Load tasks configuration profile in (.ini file) to avoid repeating same configuration twice (In progress - AutoIT Only)
      (EXPERIMENTAL) Install Apps from Microsoft Store with UIAutomation UDF made by: @junkew(Tested on Lenovo Vantage & Working)
         P.S: Installing Apps from Microsoft Store will require usage of  UIA spy tool made by @LarsJ which you can download & learn how to use it on UIA Spy Tool thread.
      ***  If this project interest you, Reply here This will greatly help me to see if you'd like this project to become real  ***
       
      Download: W10-Configurator.zip  (2021-07-19) 
      Project Website: W10-Configurator on GitHub 
      ______________________________________________________________________________________________________________________________
      Best Regards,
      ~WilliamasKumeliukas
    • By beautifulsoup
      Hi All,
      I'm not sure if its possible that I'm trying to achieve, I've looked into https://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/AutoIt3Wrapper.html and such resources for help, but I cant really find the answer to my question.
      So upon compiling the script in SciTE, the exe file is given a Description under file Properties>Details. I understand, that  one can enter info manually there and it can even implement the version automatically with each compilation.
       
      What I'm trying to achieve is to somehow include the "@ScriptName" in the Details>File Description Field. But as I see no variable can be taken after "#" in this case.
       
      Do You think its achievable? (Win 10)
       
      Much obliged for taking time on reading this.
       
      Kind Regards,
      Brave


    • By IndianSage
      Hi,
      I have a specific situation:
      Is it possible to run autoit script/.exe as a task which in turn is automating a desktop user interactive application on windows 10 where user will not be logged in - at best I can get user locked? 
      If so how will this work or is there any tool available to do this?
      I am trying z-cron task scheduler but it runs only some part also I tried windows 10 task schedule with option to allow task to run which is user interactive type but that too does not work.
      Looking forward to hear from you to help me out of this situation.
      Thanks,
       
    • By therks
      So I have no example code currently because I'm not sure where to even start.
      We're using the parental controls on the computer and the kids each have their own user profiles with limited time. The problem we're encountering is when their time runs out, or if they just hit Win+L and leave the computer, their games are still running in the background. I was hoping to write up a quick AutoIt script and throw it in a recurring scheduled task to just sign off any of the kid's profiles that's not currently active. I found some suggestions to use "query session" and then "logoff [user]" in the command line (which it seems I could easily automate with AutoIt) but that's only available on Win Pro and this system is running Home (and I even tried copying the query.exe from a Pro system but it errors out). Is there some AutoIt equivalent to the query and logoff functions or am I stuck?
      Edit: I'm adding some clarification to exactly what I'm hoping to get out of this script.
      I'd like to setup a scheduled task that runs outside of the current user (perhaps under the SYSTEM account?) in case NO user is currently active, that will detect which users are currently signed in. If users from a predefined list are not currently active, sign them off entirely.
      So let me give two examples:
      Example #1:
      - I am logged in, but not active (I left my browser open and locked the computer) - Nephew A is logged in, but not active (his time ran out while his game was running and the computer auto-locked) - Nephew B is logged in, and currently playing a game When script runs, ignore my profile (leave it signed in), log out Nephew A (closing his game), and ignore Nephew B because he's actively using the computer. Example #2:
      - I am logged in - Nephew A is logged in - Nephew B is logged in - No users are currently active (Windows is sitting on the choose user / sign in screen) When script runs, ignore my profile, log out Nephew A and Nephew B.  
      I would perceive pseudo code, going as such:
      $aChildUsers = [ 'NephewA', 'NephewB' ] $aUserList = GetSignedInUsers() For $i = 0 to UBound($aUserList)-1 If Not UserIsActive($aUserList[$i]) Then For $j = 0 to UBound($aChildUsers)-1 If $aUserList[$i] = $aChildUsers[$j] Then LogOffUser($aUserList[$i]) Next EndIf Next Obviously, GetSignedInUsers(), UserIsActive(), LogOffUser() are not real functions. What I'm searching for is something of their equivalent.
      Thanks for your time!
    • By paw
      I use SetSoundDevice to control my audio devices but the UI was either
       
      blurry like this:
      or unusable like this:

      so I made this horrible thing to add scaling to the GUI:
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Res_HiDpi=y #AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/sf /sv /rm #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <File.au3> ;~ _convertGUI("") If $CmdLine[0] <> 0 Then _convertGUI($CmdLine[1]) Func _convertGUI($sFilePath) If $sFilePath <> "" Then Local $aArray = FileReadToArray($sFilePath) Else ;TEST DATA Local $aArray[6] = ['$H_Res_Language = GUICtrlCreateProgress(5, 120, 210 + 25, 480, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE)) ; $CBS_DROPDOWNLIST)', _ 'Local $h_Ok = GUICtrlCreateButton("Ok", 72, 224, 81, 33, 0)', _ 'GUICreate($Warning_TiTle, 700, 310, -1, -1, $WS_SIZEBOX + $WS_SYSMENU + $WS_MINIMIZEBOX)', _ 'GUICtrlCreateLabel("Output type: ", 30, 130, 65, 20) ;, $SS_RIGHT)', _ '$H_FieldNameEdit = GUICtrlCreateEdit($INP_FieldNameEdit, 100,260+25, 500, 150 - 25) ;comment', 'Local $H_CANCEL = GUICtrlCreateGraphic("Cancel", 224, 224, 97, 33, 0)'] EndIf Local $hTimer = TimerInit(), $iGUIElementCount = 0, $sResult = "", $sFileName = "", $sDrive = "", $sDir = "", $sExtension = "" If @Compiled Then _PathSplit($sFilePath, $sDrive, $sDir, $sFileName, $sExtension) $sFileName = StringRegExpReplace($sFilePath, "^.*\\", "") EndIf For $i = 0 To (UBound($aArray) - 1) If StringRegExp($aArray[$i], "GUICtrlCreate|GUICreate") Then $sResult = _splitComma($aArray[$i]) If Not @error Then $aArray[$i] = $sResult $iGUIElementCount += 1 EndIf Next ConsoleWrite("t = " & TimerDiff($hTimer) & " GUI elements = " & $iGUIElementCount & " lines = " & (UBound($aArray) - 1) & @CRLF) If $sFileName <> "" Then Local $hFile = FileOpen("edited." & $sFileName, 2) _FileWriteFromArray("edited." & $sFileName, $aArray) FileClose($hFile) EndIf Exit EndFunc ;==>_convertGUI Func _splitComma($sString) Local $sSplitResult = "", $sTrimmedR = "", $sTrimmedL = "" Local $aSplit = StringSplit($sString, ',') If Not @error Then $sTrimmedR = "" $sTrimmedL = "" For $j = 1 To $aSplit[0] If StringRegExp($aSplit[1], "(?:.GUICtrlCreateGraphic|GUICtrlCreateProgress|GUICtrlCreateSlider|GUICtrlCreateTab|GUICtrlCreateTreeView)") Then If $j = 1 Then While StringLeft($aSplit[$j], 1) <> '(' $sTrimmedL &= StringLeft($aSplit[$j], 1) $aSplit[$j] = StringTrimLeft($aSplit[$j], 1) WEnd $aSplit[$j] = StringTrimLeft($aSplit[$j], 1) EndIf EndIf If $j = $aSplit[0] Then While StringRight($aSplit[$j], 1) <> ')' $sTrimmedR &= StringRight($aSplit[$j], 1) $aSplit[$j] = StringTrimRight($aSplit[$j], 1) WEnd $aSplit[$j] = StringTrimRight($aSplit[$j], 1) EndIf If StringRegExp($aSplit[$j], "[0-9]") And $aSplit[$j] <> -1 And $aSplit[$j] <> 0 And $aSplit[$j] <> 1 And Not StringInStr($aSplit[$j], ')') Then If StringRegExp($aSplit[$j], "\-|\+") Then ;put parenthesis around + or - $aSplit[$j] = '(' & $aSplit[$j] & ")*$g_DPI" Else $aSplit[$j] = $aSplit[$j] & "*$g_DPI" EndIf EndIf If $j < $aSplit[0] Then $sSplitResult &= $aSplit[$j] & ',' ElseIf $j = $aSplit[0] Then $sSplitResult &= $aSplit[$j] & ')' Else $sSplitResult &= $aSplit[$j] EndIf Next If $sTrimmedR <> "" Then $sSplitResult &= StringReverse($sTrimmedR) If $sTrimmedL <> "" Then $sSplitResult = $sTrimmedL & '(' & $sSplitResult Else SetError(1) Return EndIf ConsoleWrite($sSplitResult & @CRLF) Return $sSplitResult EndFunc ;==>_splitComma
      And now it looks good: 
      but it doesn't work on everything, for example the "GUICtrlCreateLabel("Output type: ", 30, 130, 65, 20) ;, $SS_RIGHT)" (from the autoit3wrapper gui)
      because the comment contains a parenthesis and it would break completely if there were variables as parameters..
      Is there some kind of parser around that I could use instead or maybe someone who has already done something like this?
×
×
  • Create New...