BBs19

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

198 posts in this topic

17 hours ago, Mannyfresh15 said:

I'm using this UDF now and I think it's great. However, I would like to know if there is a way to set a timeout for the msgbox and also if there is a way to enable the toggle once a function is called or launched. Does anybody know???

 

Hi, there is no timeout function built in, but I don't think that will be a problem. I will add it the next time when I fix some bugs and upload a new version.

I am not sure what u mean by "enable the toggle once a function is called or launched", why wouldn't it be possible to enable it from a function? All you have to do is add "_Metro_ToggleCheck($Toggle1)" to your function.

Share this post


Link to post
Share on other sites



#62 ·  Posted (edited)

1 hour ago, BBs19 said:

Hi, there is no timeout function built in, but I don't think that will be a problem. I will add it the next time when I fix some bugs and upload a new version.

I am not sure what u mean by "enable the toggle once a function is called or launched", why wouldn't it be possible to enable it from a function? All you have to do is add "_Metro_ToggleCheck($Toggle1)" to your function.

Well let try to explain this...

I'm writing a script which has a function and inside that function is a while loop I want to be able to toggle the toggle in the main GUI on and off while in the loop and cheek if the toggle has changed to turn the toggle function on/off while in there ...I haven't been able to achieve that. However, I can toggle the toggle before such function is called. I hope I have explained my self well enough.

 

P.S. I have achieved it with regular checkbox but a nice toggle would be nice. (: I haven't checked your new checkbox although they look nice. Will try them soon.

Edited by Mannyfresh15

Share this post


Link to post
Share on other sites
15 minutes ago, Mannyfresh15 said:

Well let try to explain this...

I'm writing a script which has a function and inside that function is a while loop I want to be able to toggle the toggle in the main GUI on and off while in the loop and cheek if the toggle has changed to turn the toggle function on/off while in there ...I haven't been able to achieve that. However, I can toggle the toggle before such function is called. I hope I have explained my self well enough.

 

P.S. I have achieved it with checkbox but a nice toggle would be nice. (:

Well then u have to do the same that you would do in your main while loop:

Func _YourFunctionWithWhileLoop()
    While 1
        _Metro_HoverCheck_Loop($Form1);To make sure that the hover effects still work
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $Toggle1
                If _Metro_ToggleIsChecked($Toggle1) Then
                    _Metro_ToggleUnCheck($Toggle1)
                    ConsoleWrite("Toggle unchecked!" & @CRLF)
                Else
                    _Metro_ToggleCheck($Toggle1)
                    ConsoleWrite("Toggle checked!" & @CRLF)
                EndIf
        EndSwitch
    WEnd
EndFunc

If you use anything like a msgbox or sleep function etc. that will pause your script, then it won't work. 

Share this post


Link to post
Share on other sites
1 hour ago, BBs19 said:

Well then u have to do the same that you would do in your main while loop:

Func _YourFunctionWithWhileLoop()
    While 1
        _Metro_HoverCheck_Loop($Form1);To make sure that the hover effects still work
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $Toggle1
                If _Metro_ToggleIsChecked($Toggle1) Then
                    _Metro_ToggleUnCheck($Toggle1)
                    ConsoleWrite("Toggle unchecked!" & @CRLF)
                Else
                    _Metro_ToggleCheck($Toggle1)
                    ConsoleWrite("Toggle checked!" & @CRLF)
                EndIf
        EndSwitch
    WEnd
EndFunc

If you use anything like a msgbox or sleep function etc. that will pause your script, then it won't work. 

It works!!! However, it gets stuck I have to click it many times sometimes in order to toggle it on/off. I'm not using sleep not anything that would make the script pause... Anyway thank you so much for your help I really appreciated.

 

Share this post


Link to post
Share on other sites

I also would like to know if there is a way to make the Metro GUIs draggable but not resizable.

Share this post


Link to post
Share on other sites
16 hours ago, Mannyfresh15 said:

It works!!! However, it gets stuck I have to click it many times sometimes in order to toggle it on/off. I'm not using sleep not anything that would make the script pause... Anyway thank you so much for your help I really appreciated.

 

Can you show me your code? It is really hard to understand what you are trying to do there, as it is working fine for me.

 

12 hours ago, Mannyfresh15 said:

I also would like to know if there is a way to make the Metro GUIs draggable but not resizable.

There are many different ways to do that, see here: https://www.autoitscript.com/wiki/Moving_and_Resizing_PopUp_GUIs#Moving_a_.24WS_POPUP_GUI

You can also use an internal function of my UDF. Just add this to your script:

$GLOBAL_MAIN_GUI = $Form1 ; ($Form1 should be replaced by the variable name of your created GUI)
GUIRegisterMsg(0x0201, "INTERNAL_WM_LBUTTONDOWN")


 

Share this post


Link to post
Share on other sites

#67 ·  Posted (edited)

12 hours ago, BBs19 said:

Can you show me your code? It is really hard to understand what you are trying to do there, as it is working fine for me.

 

There are many different ways to do that, see here: https://www.autoitscript.com/wiki/Moving_and_Resizing_PopUp_GUIs#Moving_a_.24WS_POPUP_GUI

You can also use an internal function of my UDF. Just add this to your script:

$GLOBAL_MAIN_GUI = $Form1 ; ($Form1 should be replaced by the variable name of your created GUI)
GUIRegisterMsg(0x0201, "INTERNAL_WM_LBUTTONDOWN")


 

Yes here is an example code excuse the DIRTY code since I'm a beginner plus I have borrowed part of it ): Anyway I have notice that "Abort" button has the same problem while in the loop and if I used regular GUI that is not Metro  works just fine. Please let me know if you need a sample code of a regular GUI so you can see it works fine.

#include-once

#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <MsgBoxConstants.au3>
#include <Timers.au3>
#include <Sound.au3>
#include <MetroGUI_UDF.au3>


#NoTrayIcon

;!Highly recommended for improved overall performance and responsiveness of the GUI effects etc.! (after compiling):
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so /rm /pe

;Required if you want High DPI scaling enabled. (Also requries _Metro_EnableHighDPIScaling())
#AutoIt3Wrapper_Res_HiDpi=y


$Form1 = ""


$Checked = False

$timer = ""

$RED = 1

$sec = @SEC

 $Tiempo = ""

$Alarm =  "C:\Users\Admin\Downloads\BOMB_SIREN-BOMB_SIREN-247265934.wav" ;Replace this with your own .wav file. you already knew this what the heck



; Setting Time Variables
$5m =  300000
$10m = 600000
$15m = 900250
$30m = 1800500
$45m = 2700750
$1h = 3601000


$GLOBAL_MAIN_GUI = $Form1 ; ($Form1 should be replaced by the variable name of your created GUI)
GUIRegisterMsg(0x0201, "INTERNAL_WM_LBUTTONDOWN")


;=======================================================================Creating the GUI===============================================================================
;Set Theme
_SetTheme("DarkBlue") ;See MetroThemes.au3 for selectable themes or to add more

;Enable high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp.
_Metro_EnableHighDPIScaling() ; Note: Requries "#AutoIt3Wrapper_Res_HiDpi=y" for compiling. To see visible changes without compiling, you have to disable dpi scaling in compatibility settings of Autoit3.exe

;Create resizable Metro GUI
$GLOBAL_MAIN_GUI = _Metro_CreateGUI("My app",  484, 209, 255, 124,False)


;Add/create control buttons to the gui
$Control_Buttons = _Metro_AddControlButtons(True, False, True, False, False) ;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]
GUICtrlSetTip($GUI_CLOSE_BUTTON , "Close")
$GUI_MAXIMIZE_BUTTON = $Control_Buttons[1]
;GUICtrlSetTip($GUI_MAXIMIZE_BUTTON , "Minimizar")
$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]
GUICtrlSetTip($GUI_MENU_BUTTON , "Menu")
;======================================================================================================================================================================

;Create  Buttons
$Button1 = _Metro_CreateButton("start", 206, 177, 75, 25)
$Button2 = _Metro_CreateButton("Abort", 380, 177, 75, 25)

;Create Toggle
$Toggle1 = _Metro_CreateToggle ("Alarm", 10, 147,120,34)
GUICtrlSetTip($Toggle1 , "On/Off")



#Region ### START Koda GUI section ### Form=

$Label1 = GUICtrlCreateLabel("My Timer", 45, 119, 366, 33, $SS_CENTER)
GUICtrlSetColor($Label1,0xFFFFFF)
GUICtrlSetFont(-1, 16, 0, 0, "Impact")

; Create a combobox control.
$idComboBox = GUICtrlCreateCombo("Select Time", 110, 181, 90, 21)
GUICtrlSetTip(-1, "Select Time")
; Add additional items to the combobox.
GUICtrlSetData($idComboBox, "5 Minutes|10 Minutes|15 Minutes|30 Minutes|45 Minutes|1 Hour", "Select Time")
;
$Label2 = GUICtrlCreateLabel("How much Time?", 4, 183, 100, 25, $SS_CENTER)
GUICtrlSetColor(-1,0xFFFFFF)
$Inputtimer = GUICtrlCreateInput("00:00:00", 380, 147, 75, 20, BitOr($SS_CENTER, $ES_READONLY))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
   _Metro_HoverCheck_Loop($GLOBAL_MAIN_GUI)
    $nMsg = GUIGetMsg()
    Switch $nMsg

ExitLoop
Exit

         case $Button1

            startTimer ()



             Case $Button2

            exit

         Case  $GUI_CLOSE_BUTTON


              ExitLoop
               Exit

    Case $GUI_MINIMIZE_BUTTON
            GUISetState(@SW_MINIMIZE)




              Case $Toggle1

         If _Metro_ToggleIsChecked($Toggle1) Then
            _Metro_ToggleUnCheck($Toggle1)
            $Checked = False

        Else
                _Metro_ToggleCheck($Toggle1)

                $Checked = True


            EndIf


                EndSwitch


WEnd




Func startTimer  ()

$Comboread = GUICtrlRead($idComboBox, 0)
if $Comboread = 0 Then

MsgBox($MB_SYSTEMMODAL, "Warning ",  "You Haven't Selected Any Time",10)
Return
Else


if $Comboread =  "5 Minutes" Then $Tiempo = $5m
if $Comboread =  "10 Minutes" Then $Tiempo = $10m
if $Comboread =  "15 Minutes" Then $Tiempo = $15m
if $Comboread =  "30 Minutes" Then $Tiempo = $30m
if $Comboread =  "45 Minutes" Then $Tiempo = $45m
if $Comboread =  "1 Hour" Then $Tiempo = $1h


     ;setting warning labels
      $lbl_text = GUICtrlCreateLabel("Notice", 190, 149, 85, 17,$SS_CENTER)
    ;GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
GUICtrlSetColor($lbl_text,0xff0000)  ; Red
GUICtrlSetFont($lbl_text,9,700)
;
 $lbl_text2 = GUICtrlCreateLabel("Timer will stop in:", 250, 150, 125, 20, $SS_CENTER)
;GUICtrlSetResizing(-1, )
GUICtrlSetColor(-1,0xFFFFFF)

   ; call ("startTimer2 ")


EndIf


;Checking if timer is greater than 0
   If TimerDiff($timer) > 0 Then
$timer = TimerInit()


EndIf




   While( TimerDiff($timer)  < $Tiempo) and (GUIGetMsg() <> $Button2)



;Setting Toggle
_Metro_HoverCheck_Loop($Form1);To make sure that the hover effects still work
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $Toggle1
                If _Metro_ToggleIsChecked($Toggle1) Then
                    _Metro_ToggleUnCheck($Toggle1)

                    $Checked = False
                Else
                    _Metro_ToggleCheck($Toggle1)

                    $Checked = True
                 EndIf

                 Case $GUI_MINIMIZE_BUTTON
            GUISetState(@SW_MINIMIZE)

        EndSwitch



$seconds = TimerDiff($timer)/1000
$diff = $seconds - ($Tiempo/1000)
;
$minutes = Int($diff / 60)
$secondsRem = $diff - ($minutes * 60)
;
$hours = Int($minutes / 60)
$minutes =  $minutes - ($hours * 60)

;
$hours =  $hours * -1
$minutes = $minutes * -1
$secondsRem = $secondsRem * -1

;

$time = StringFormat("%02d", $hours) & ":" & StringFormat("%02d", $minutes) & ":" & StringFormat("%02d", $secondsRem)
;
GUICtrlSetData($Inputtimer, $time)



;Checks if timer is higher than 3mins and If toggle is on plays Sound
if   TimerDiff($timer) > $Tiempo - 180000 And $Checked = True  Then  _SoundPlay ($Alarm,0) ;MsgBox(0,"Aviso","Alarma",5)


;Checks if timer is higher than 3mins and If toggle is off checked stops Sound

if   TimerDiff($timer) > $Tiempo - 180000 And $Checked = False Then  _SoundStop ($Alarm)






; Blinking Text





        If @SEC <> $sec Then
            $sec = @SEC
            If $RED Then
                GUICtrlSetColor($lbl_text,0xffffff)
            Else
                GUICtrlSetColor($lbl_text,0xff0000)
            EndIf
            $RED = Not $RED
         EndIf




WEnd





$Readtimer = GUICtrlRead ($Inputtimer,0)
if $Readtimer = "00:00:00" then
 MsgBox($MB_ICONWARNING, "Notice", "Time is Up!",15)

_SoundStop ($Alarm)



Else
 _SoundStop ($Alarm)
GUICtrlSetData($Inputtimer, "00:00:00")
GUICtrlDelete ($lbl_text2)
GUICtrlDelete ($lbl_text)

EndIf



   EndFunc

 

And your

 

$GLOBAL_MAIN_GUI = $Form1 ; ($Form1 should be replaced by the variable name of your created GUI)
GUIRegisterMsg(0x0201, "INTERNAL_WM_LBUTTONDOWN")

Works Just Fine I hope I can get a solution for the toggle and the button problem

Edited by Mannyfresh15

Share this post


Link to post
Share on other sites

#68 ·  Posted (edited)

21 hours ago, Mannyfresh15 said:

Works Just Fine I hope I can get a solution for the toggle and the button problem

This was somehow causing the problem:

While( TimerDiff($timer)  < $Tiempo) and (GUIGetMsg() <> $Button2)

 

Try with this:

#NoTrayIcon
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <MsgBoxConstants.au3>
#include <Timers.au3>
#include <Sound.au3>
#include <MetroGUI_UDF.au3>

;!Highly recommended for improved overall performance and responsiveness of the GUI effects etc.! (after compiling):
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so /rm /pe

;Required if you want High DPI scaling enabled. (Also requries _Metro_EnableHighDPIScaling())
#AutoIt3Wrapper_Res_HiDpi=y

$Checked = False
$timer = ""
$RED = 1
$sec = @SEC
$Tiempo = ""
$Alarm = "C:\Users\Admin\Downloads\BOMB_SIREN-BOMB_SIREN-247265934.wav" ;Replace this with your own .wav file. you already knew this what the heck

; Setting Time Variables
$5m = 300000
$10m = 600000
$15m = 900250
$30m = 1800500
$45m = 2700750
$1h = 3601000

;=======================================================================Creating the GUI===============================================================================
;Set Theme
_SetTheme("DarkBlue") ;See MetroThemes.au3 for selectable themes or to add more

;Enable high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp.
_Metro_EnableHighDPIScaling() ; Note: Requries "#AutoIt3Wrapper_Res_HiDpi=y" for compiling. To see visible changes without compiling, you have to disable dpi scaling in compatibility settings of Autoit3.exe

;Create resizable Metro GUI
$GLOBAL_MAIN_GUI = _Metro_CreateGUI("My app", 484, 209, 255, 124, False)

;Add/create control buttons to the gui
$Control_Buttons = _Metro_AddControlButtons(True, False, True, False, False) ;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]
GUICtrlSetTip($GUI_CLOSE_BUTTON, "Close")
$GUI_MAXIMIZE_BUTTON = $Control_Buttons[1]
;GUICtrlSetTip($GUI_MAXIMIZE_BUTTON , "Minimizar")
$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]
GUICtrlSetTip($GUI_MENU_BUTTON, "Menu")
;======================================================================================================================================================================

;Create  Buttons
$Button1 = _Metro_CreateButton("start", 206, 177, 75, 25)
$Button2 = _Metro_CreateButton("Abort", 380, 177, 75, 25)

;Create Toggle
$Toggle1 = _Metro_CreateToggle("Alarm", 10, 147, 120, 34)
GUICtrlSetTip($Toggle1, "On/Off")

#Region ### START Koda GUI section ### Form=
$Label1 = GUICtrlCreateLabel("My Timer", 45, 119, 366, 33, $SS_CENTER)
GUICtrlSetColor($Label1, 0xFFFFFF)
GUICtrlSetFont(-1, 16, 0, 0, "Impact")

; Create a combobox control.
$idComboBox = GUICtrlCreateCombo("Select Time", 110, 181, 90, 21)
GUICtrlSetTip(-1, "Select Time")
; Add additional items to the combobox.
GUICtrlSetData($idComboBox, "5 Minutes|10 Minutes|15 Minutes|30 Minutes|45 Minutes|1 Hour", "Select Time")
;
$Label2 = GUICtrlCreateLabel("How much Time?", 4, 183, 100, 25, $SS_CENTER)
GUICtrlSetColor(-1, 0xFFFFFF)
$Inputtimer = GUICtrlCreateInput("00:00:00", 380, 147, 75, 20, BitOR($SS_CENTER, $ES_READONLY))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUIRegisterMsg(0x0201, "INTERNAL_WM_LBUTTONDOWN")

While 1
    _Metro_HoverCheck_Loop($GLOBAL_MAIN_GUI)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Button1
            startTimer()
        Case $Button2
            Exit
        Case $GUI_CLOSE_BUTTON
            ExitLoop
            Exit
        Case $GUI_MINIMIZE_BUTTON
            GUISetState(@SW_MINIMIZE)
        Case $Toggle1
            If _Metro_ToggleIsChecked($Toggle1) Then
                _Metro_ToggleUnCheck($Toggle1)
                $Checked = False
            Else
                _Metro_ToggleCheck($Toggle1)
                $Checked = True
            EndIf
    EndSwitch
WEnd

Func startTimer()

    $Comboread = GUICtrlRead($idComboBox, 0)
    If $Comboread = 0 Then
        MsgBox($MB_SYSTEMMODAL, "Warning ", "You Haven't Selected Any Time", 10)
        Return
    Else
        If $Comboread = "5 Minutes" Then $Tiempo = $5m
        If $Comboread = "10 Minutes" Then $Tiempo = $10m
        If $Comboread = "15 Minutes" Then $Tiempo = $15m
        If $Comboread = "30 Minutes" Then $Tiempo = $30m
        If $Comboread = "45 Minutes" Then $Tiempo = $45m
        If $Comboread = "1 Hour" Then $Tiempo = $1h
        ;setting warning labels
        $lbl_text = GUICtrlCreateLabel("Notice", 190, 149, 85, 17, $SS_CENTER)
        ;GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
        GUICtrlSetColor($lbl_text, 0xff0000) ; Red
        GUICtrlSetFont($lbl_text, 9, 700)
        ;
        $lbl_text2 = GUICtrlCreateLabel("Timer will stop in:", 250, 150, 125, 20, $SS_CENTER)
        ;GUICtrlSetResizing(-1, )
        GUICtrlSetColor(-1, 0xFFFFFF)
        ; call ("startTimer2 ")
    EndIf

    ;Checking if timer is greater than 0
    If TimerDiff($timer) > 0 Then
        $timer = TimerInit()
    EndIf

    While (TimerDiff($timer) < $Tiempo)
        ;Setting Toggle
        _Metro_HoverCheck_Loop($GLOBAL_MAIN_GUI) ;To make sure that the hover effects still work
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $Toggle1
                If _Metro_ToggleIsChecked($Toggle1) Then
                    _Metro_ToggleUnCheck($Toggle1)
                    $Checked = False
                Else
                    _Metro_ToggleCheck($Toggle1)
                    $Checked = True
                EndIf
            Case $GUI_MINIMIZE_BUTTON
                GUISetState(@SW_MINIMIZE)
            Case $Button2
                ExitLoop
            Case $GUI_CLOSE_BUTTON
                Exit
        EndSwitch

        $seconds = TimerDiff($timer) / 1000
        $diff = $seconds - ($Tiempo / 1000)
        ;
        $minutes = Int($diff / 60)
        $secondsRem = $diff - ($minutes * 60)
        ;
        $hours = Int($minutes / 60)
        $minutes = $minutes - ($hours * 60)

        ;
        $hours = $hours * -1
        $minutes = $minutes * -1
        $secondsRem = $secondsRem * -1

        $time = StringFormat("%02d", $hours) & ":" & StringFormat("%02d", $minutes) & ":" & StringFormat("%02d", $secondsRem)
        ;
        GUICtrlSetData($Inputtimer, $time)

        ;Checks if timer is higher than 3mins and If toggle is on plays Sound
        If TimerDiff($timer) > $Tiempo - 180000 And $Checked = True Then _SoundPlay($Alarm, 0) ;MsgBox(0,"Aviso","Alarma",5)

        ;Checks if timer is higher than 3mins and If toggle is off checked stops Sound

        If TimerDiff($timer) > $Tiempo - 180000 And $Checked = False Then _SoundStop($Alarm)

        ; Blinking Text

        If @SEC <> $sec Then
            $sec = @SEC
            If $RED Then
                GUICtrlSetColor($lbl_text, 0xffffff)
            Else
                GUICtrlSetColor($lbl_text, 0xff0000)
            EndIf
            $RED = Not $RED
        EndIf

    WEnd

    $Readtimer = GUICtrlRead($Inputtimer, 0)
    If $Readtimer = "00:00:00" Then
        MsgBox($MB_ICONWARNING, "Notice", "Time is Up!", 15)
        _SoundStop($Alarm)
    Else
        _SoundStop($Alarm)
        GUICtrlSetData($Inputtimer, "00:00:00")
        GUICtrlDelete($lbl_text2)
        GUICtrlDelete($lbl_text)
    EndIf

EndFunc   ;==>startTimer

 

Edited by BBs19

Share this post


Link to post
Share on other sites

Hi BBs19,

What would be the font setting to use in order to maintain overall consistency with the created controls (checkbox/radio/toggle).
I'd like to for example add a label control but want the text to look the same as your controls.

Share this post


Link to post
Share on other sites

#70 ·  Posted (edited)

7 hours ago, Dreamfire said:

Hi BBs19,

What would be the font setting to use in order to maintain overall consistency with the created controls (checkbox/radio/toggle).
I'd like to for example add a label control but want the text to look the same as your controls.

 

Hi, the default font is mostly Segoe UI, only Buttons are set to Arial. You can change the default font of course, just look at the the MetroGUI_UDF.au3 file for syntax, the example file i posted is kept pretty easy without much customization:)

Edited by BBs19

Share this post


Link to post
Share on other sites

#71 ·  Posted (edited)

On 6/12/2016 at 6:18 AM, BBs19 said:

This was somehow causing the problem:

While( TimerDiff($timer)  < $Tiempo) and (GUIGetMsg() <> $Button2)

 

Try with this:

#NoTrayIcon
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <MsgBoxConstants.au3>
#include <Timers.au3>
#include <Sound.au3>
#include <MetroGUI_UDF.au3>

;!Highly recommended for improved overall performance and responsiveness of the GUI effects etc.! (after compiling):
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so /rm /pe

;Required if you want High DPI scaling enabled. (Also requries _Metro_EnableHighDPIScaling())
#AutoIt3Wrapper_Res_HiDpi=y

$Checked = False
$timer = ""
$RED = 1
$sec = @SEC
$Tiempo = ""
$Alarm = "C:\Users\Admin\Downloads\BOMB_SIREN-BOMB_SIREN-247265934.wav" ;Replace this with your own .wav file. you already knew this what the heck

; Setting Time Variables
$5m = 300000
$10m = 600000
$15m = 900250
$30m = 1800500
$45m = 2700750
$1h = 3601000

;=======================================================================Creating the GUI===============================================================================
;Set Theme
_SetTheme("DarkBlue") ;See MetroThemes.au3 for selectable themes or to add more

;Enable high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp.
_Metro_EnableHighDPIScaling() ; Note: Requries "#AutoIt3Wrapper_Res_HiDpi=y" for compiling. To see visible changes without compiling, you have to disable dpi scaling in compatibility settings of Autoit3.exe

;Create resizable Metro GUI
$GLOBAL_MAIN_GUI = _Metro_CreateGUI("My app", 484, 209, 255, 124, False)

;Add/create control buttons to the gui
$Control_Buttons = _Metro_AddControlButtons(True, False, True, False, False) ;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]
GUICtrlSetTip($GUI_CLOSE_BUTTON, "Close")
$GUI_MAXIMIZE_BUTTON = $Control_Buttons[1]
;GUICtrlSetTip($GUI_MAXIMIZE_BUTTON , "Minimizar")
$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]
GUICtrlSetTip($GUI_MENU_BUTTON, "Menu")
;======================================================================================================================================================================

;Create  Buttons
$Button1 = _Metro_CreateButton("start", 206, 177, 75, 25)
$Button2 = _Metro_CreateButton("Abort", 380, 177, 75, 25)

;Create Toggle
$Toggle1 = _Metro_CreateToggle("Alarm", 10, 147, 120, 34)
GUICtrlSetTip($Toggle1, "On/Off")

#Region ### START Koda GUI section ### Form=
$Label1 = GUICtrlCreateLabel("My Timer", 45, 119, 366, 33, $SS_CENTER)
GUICtrlSetColor($Label1, 0xFFFFFF)
GUICtrlSetFont(-1, 16, 0, 0, "Impact")

; Create a combobox control.
$idComboBox = GUICtrlCreateCombo("Select Time", 110, 181, 90, 21)
GUICtrlSetTip(-1, "Select Time")
; Add additional items to the combobox.
GUICtrlSetData($idComboBox, "5 Minutes|10 Minutes|15 Minutes|30 Minutes|45 Minutes|1 Hour", "Select Time")
;
$Label2 = GUICtrlCreateLabel("How much Time?", 4, 183, 100, 25, $SS_CENTER)
GUICtrlSetColor(-1, 0xFFFFFF)
$Inputtimer = GUICtrlCreateInput("00:00:00", 380, 147, 75, 20, BitOR($SS_CENTER, $ES_READONLY))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUIRegisterMsg(0x0201, "INTERNAL_WM_LBUTTONDOWN")

While 1
    _Metro_HoverCheck_Loop($GLOBAL_MAIN_GUI)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Button1
            startTimer()
        Case $Button2
            Exit
        Case $GUI_CLOSE_BUTTON
            ExitLoop
            Exit
        Case $GUI_MINIMIZE_BUTTON
            GUISetState(@SW_MINIMIZE)
        Case $Toggle1
            If _Metro_ToggleIsChecked($Toggle1) Then
                _Metro_ToggleUnCheck($Toggle1)
                $Checked = False
            Else
                _Metro_ToggleCheck($Toggle1)
                $Checked = True
            EndIf
    EndSwitch
WEnd

Func startTimer()

    $Comboread = GUICtrlRead($idComboBox, 0)
    If $Comboread = 0 Then
        MsgBox($MB_SYSTEMMODAL, "Warning ", "You Haven't Selected Any Time", 10)
        Return
    Else
        If $Comboread = "5 Minutes" Then $Tiempo = $5m
        If $Comboread = "10 Minutes" Then $Tiempo = $10m
        If $Comboread = "15 Minutes" Then $Tiempo = $15m
        If $Comboread = "30 Minutes" Then $Tiempo = $30m
        If $Comboread = "45 Minutes" Then $Tiempo = $45m
        If $Comboread = "1 Hour" Then $Tiempo = $1h
        ;setting warning labels
        $lbl_text = GUICtrlCreateLabel("Notice", 190, 149, 85, 17, $SS_CENTER)
        ;GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
        GUICtrlSetColor($lbl_text, 0xff0000) ; Red
        GUICtrlSetFont($lbl_text, 9, 700)
        ;
        $lbl_text2 = GUICtrlCreateLabel("Timer will stop in:", 250, 150, 125, 20, $SS_CENTER)
        ;GUICtrlSetResizing(-1, )
        GUICtrlSetColor(-1, 0xFFFFFF)
        ; call ("startTimer2 ")
    EndIf

    ;Checking if timer is greater than 0
    If TimerDiff($timer) > 0 Then
        $timer = TimerInit()
    EndIf

    While (TimerDiff($timer) < $Tiempo)
        ;Setting Toggle
        _Metro_HoverCheck_Loop($GLOBAL_MAIN_GUI) ;To make sure that the hover effects still work
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $Toggle1
                If _Metro_ToggleIsChecked($Toggle1) Then
                    _Metro_ToggleUnCheck($Toggle1)
                    $Checked = False
                Else
                    _Metro_ToggleCheck($Toggle1)
                    $Checked = True
                EndIf
            Case $GUI_MINIMIZE_BUTTON
                GUISetState(@SW_MINIMIZE)
            Case $Button2
                ExitLoop
            Case $GUI_CLOSE_BUTTON
                Exit
        EndSwitch

        $seconds = TimerDiff($timer) / 1000
        $diff = $seconds - ($Tiempo / 1000)
        ;
        $minutes = Int($diff / 60)
        $secondsRem = $diff - ($minutes * 60)
        ;
        $hours = Int($minutes / 60)
        $minutes = $minutes - ($hours * 60)

        ;
        $hours = $hours * -1
        $minutes = $minutes * -1
        $secondsRem = $secondsRem * -1

        $time = StringFormat("%02d", $hours) & ":" & StringFormat("%02d", $minutes) & ":" & StringFormat("%02d", $secondsRem)
        ;
        GUICtrlSetData($Inputtimer, $time)

        ;Checks if timer is higher than 3mins and If toggle is on plays Sound
        If TimerDiff($timer) > $Tiempo - 180000 And $Checked = True Then _SoundPlay($Alarm, 0) ;MsgBox(0,"Aviso","Alarma",5)

        ;Checks if timer is higher than 3mins and If toggle is off checked stops Sound

        If TimerDiff($timer) > $Tiempo - 180000 And $Checked = False Then _SoundStop($Alarm)

        ; Blinking Text

        If @SEC <> $sec Then
            $sec = @SEC
            If $RED Then
                GUICtrlSetColor($lbl_text, 0xffffff)
            Else
                GUICtrlSetColor($lbl_text, 0xff0000)
            EndIf
            $RED = Not $RED
        EndIf

    WEnd

    $Readtimer = GUICtrlRead($Inputtimer, 0)
    If $Readtimer = "00:00:00" Then
        MsgBox($MB_ICONWARNING, "Notice", "Time is Up!", 15)
        _SoundStop($Alarm)
    Else
        _SoundStop($Alarm)
        GUICtrlSetData($Inputtimer, "00:00:00")
        GUICtrlDelete($lbl_text2)
        GUICtrlDelete($lbl_text)
    EndIf

EndFunc   ;==>startTimer

 

You're badass! all those problems have been taken care of thanks to you (:

Now I just got into a little problem setting up a picture as a background will make overlapping controls not work check my example below

 

#NoTrayIcon
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <MsgBoxConstants.au3>
#include <Timers.au3>
#include <Sound.au3>
#include <MetroGUI_UDF.au3>

;!Highly recommended for improved overall performance and responsiveness of the GUI effects etc.! (after compiling):
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so /rm /pe

;Required if you want High DPI scaling enabled. (Also requries _Metro_EnableHighDPIScaling())
#AutoIt3Wrapper_Res_HiDpi=y

$Checked = False
$timer = ""
$RED = 1
$sec = @SEC
$Tiempo = ""
$Alarm = "C:\Users\Admin\Downloads\BOMB_SIREN-BOMB_SIREN-247265934.wav" ;Replace this with your own .wav file. you already knew this what the heck

; Setting Time Variables
$5m = 300000
$10m = 600000
$15m = 900250
$30m = 1800500
$45m = 2700750
$1h = 3601000

InetGet ("http://imgur.com/download/C5CE14x/" ,@TempDir & "\Samplepic.jpg")

;=======================================================================Creating the GUI===============================================================================
;Set Theme
_SetTheme("DarkBlue") ;See MetroThemes.au3 for selectable themes or to add more

;Enable high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp.
_Metro_EnableHighDPIScaling() ; Note: Requries "#AutoIt3Wrapper_Res_HiDpi=y" for compiling. To see visible changes without compiling, you have to disable dpi scaling in compatibility settings of Autoit3.exe

;Create resizable Metro GUI
$GLOBAL_MAIN_GUI = _Metro_CreateGUI("My app", 484, 209, 255, 124, False)

$Pic1 = GUICtrlCreatePic(@TempDir & "\Samplepic.jpg", 10, 0, 460, 119, $SS_NOTIFY,$GUI_WS_EX_PARENTDRAG)
;GuiCtrlSetState(-1,$GUI_DISABLE) If I uncomment this others controls will work but drag will not. ):
;Create an Array containing menu button names
Dim $MenuButtonsArray[4] = ["Settings", "About", "Contact", "Exit"]

;Add/create control buttons to the gui
$Control_Buttons = _Metro_AddControlButtons(True, False, True, 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]
GUICtrlSetTip($GUI_CLOSE_BUTTON, "Close")
$GUI_MAXIMIZE_BUTTON = $Control_Buttons[1]
;GUICtrlSetTip($GUI_MAXIMIZE_BUTTON , "Minimizar")
$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]
GUICtrlSetTip($GUI_MENU_BUTTON, "Menu")
;======================================================================================================================================================================

;Create  Buttons
$Button1 = _Metro_CreateButton("start", 206, 177, 75, 25)
$Button2 = _Metro_CreateButton("Abort", 380, 177, 75, 25)

;Create Toggle
$Toggle1 = _Metro_CreateToggle("Alarm", 10, 147, 120, 34)
GUICtrlSetTip($Toggle1, "On/Off")

#Region ### START Koda GUI section ### Form=
$Label1 = GUICtrlCreateLabel("My Timer", 45, 119, 366, 33, $SS_CENTER,$GUI_WS_EX_PARENTDRAG)
GUICtrlSetColor($Label1, 0xFFFFFF)
GUICtrlSetFont(-1, 16, 0, 0, "Impact")

; Create a combobox control.
$idComboBox = GUICtrlCreateCombo("Select Time", 110, 181, 90, 21)
GUICtrlSetTip(-1, "Select Time")
; Add additional items to the combobox.
GUICtrlSetData($idComboBox, "5 Minutes|10 Minutes|15 Minutes|30 Minutes|45 Minutes|1 Hour", "Select Time")
;
$Label2 = GUICtrlCreateLabel("How much Time?", 4, 183, 100, 25, $SS_CENTER,$GUI_WS_EX_PARENTDRAG)
GUICtrlSetColor(-1, 0xFFFFFF)
$Inputtimer = GUICtrlCreateInput("00:00:00", 380, 147, 75, 20, BitOR($SS_CENTER, $ES_READONLY))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUIRegisterMsg(0x0201, "INTERNAL_WM_LBUTTONDOWN")

While 1
    _Metro_HoverCheck_Loop($GLOBAL_MAIN_GUI)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Button1
            startTimer()
        Case $Button2
            Exit
        Case $GUI_CLOSE_BUTTON
            ExitLoop
            Exit
        Case $GUI_MINIMIZE_BUTTON
            GUISetState(@SW_MINIMIZE)
        Case $Toggle1
            If _Metro_ToggleIsChecked($Toggle1) Then
                _Metro_ToggleUnCheck($Toggle1)
                $Checked = False
            Else
                _Metro_ToggleCheck($Toggle1)
                $Checked = True
             EndIf

            Case $GUI_MENU_BUTTON
            Local $MenuSelect = _Metro_MenuStart($GLOBAL_MAIN_GUI, $GUI_MENU_BUTTON, 150, $MenuButtonsArray) ; Opens the metro Menu. See decleration of $MenuButtonsArray above.
            Switch $MenuSelect ;Above function returns the index number of the 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)
                    Exit

    EndSwitch

    EndSwitch
WEnd

Func startTimer()

    $Comboread = GUICtrlRead($idComboBox, 0)
    If $Comboread = 0 Then
        MsgBox($MB_SYSTEMMODAL, "Warning ", "You Haven't Selected Any Time", 10)
        Return
    Else
        If $Comboread = "5 Minutes" Then $Tiempo = $5m
        If $Comboread = "10 Minutes" Then $Tiempo = $10m
        If $Comboread = "15 Minutes" Then $Tiempo = $15m
        If $Comboread = "30 Minutes" Then $Tiempo = $30m
        If $Comboread = "45 Minutes" Then $Tiempo = $45m
        If $Comboread = "1 Hour" Then $Tiempo = $1h
        ;setting warning labels
        $lbl_text = GUICtrlCreateLabel("Attention!", 180, 149, 80, 17, $SS_CENTER,$GUI_WS_EX_PARENTDRAG)
        ;GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
        GUICtrlSetColor($lbl_text, 0xff0000) ; Red
        GUICtrlSetFont($lbl_text, 9, 700)
        ;
        $lbl_text2 = GUICtrlCreateLabel("Timer will stop in:", 250, 150, 125, 20, $SS_CENTER,$GUI_WS_EX_PARENTDRAG)
        ;GUICtrlSetResizing(-1, )
        GUICtrlSetColor(-1, 0xFFFFFF)
        ; call ("startTimer2 ")
    EndIf

    ;Checking if timer is greater than 0
    If TimerDiff($timer) > 0 Then
        $timer = TimerInit()
    EndIf

    While (TimerDiff($timer) < $Tiempo)
        ;Setting Toggle
        _Metro_HoverCheck_Loop($GLOBAL_MAIN_GUI) ;To make sure that the hover effects still work
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $Toggle1
                If _Metro_ToggleIsChecked($Toggle1) Then
                    _Metro_ToggleUnCheck($Toggle1)
                    $Checked = False
                Else
                    _Metro_ToggleCheck($Toggle1)
                    $Checked = True
                EndIf
            Case $GUI_MINIMIZE_BUTTON
                GUISetState(@SW_MINIMIZE)
            Case $Button2
                ExitLoop
            Case $GUI_CLOSE_BUTTON
                Exit
        EndSwitch

        $seconds = TimerDiff($timer) / 1000
        $diff = $seconds - ($Tiempo / 1000)
        ;
        $minutes = Int($diff / 60)
        $secondsRem = $diff - ($minutes * 60)
        ;
        $hours = Int($minutes / 60)
        $minutes = $minutes - ($hours * 60)

        ;
        $hours = $hours * -1
        $minutes = $minutes * -1
        $secondsRem = $secondsRem * -1

        $time = StringFormat("%02d", $hours) & ":" & StringFormat("%02d", $minutes) & ":" & StringFormat("%02d", $secondsRem)
        ;
        GUICtrlSetData($Inputtimer, $time)

        ;Checks if timer is higher than 3mins and If toggle is on plays Sound
        If TimerDiff($timer) > $Tiempo - 180000 And $Checked = True Then _SoundPlay($Alarm, 0) ;MsgBox(0,"Aviso","Alarma",5)

        ;Checks if timer is higher than 3mins and If toggle is off checked stops Sound

        If TimerDiff($timer) > $Tiempo - 180000 And $Checked = False Then _SoundStop($Alarm)

        ; Blinking Text

        If @SEC <> $sec Then
            $sec = @SEC
            If $RED Then
                GUICtrlSetColor($lbl_text, 0xffffff)
            Else
                GUICtrlSetColor($lbl_text, 0xff0000)
            EndIf
            $RED = Not $RED
        EndIf

    WEnd

    $Readtimer = GUICtrlRead($Inputtimer, 0)
    If $Readtimer = "00:00:00" Then
        MsgBox($MB_ICONWARNING, "Notice", "Time is Up!", 15)
        _SoundStop($Alarm)
    Else
        _SoundStop($Alarm)
        GUICtrlSetData($Inputtimer, "00:00:00")
        GUICtrlDelete($lbl_text2)
        GUICtrlDelete($lbl_text)
    EndIf

EndFunc   ;==>startTimer

 

I having Problems with this:

$Pic1 = GUICtrlCreatePic(@TempDir & "\Samplepic.jpg", 10, 0, 460, 119, $SS_NOTIFY,$GUI_WS_EX_PARENTDRAG)
;GuiCtrlSetState(-1,$GUI_DISABLE) If I uncomment this others controls will work but drag will not. ):

 I don't wanna sound like if I'm getting advantage of you but I really would like to get some help on this because I have no problem with regular GUI but I really want to use Metro GUIs and you know you're the expert. (: 

Edited by Mannyfresh15

Share this post


Link to post
Share on other sites

How can i change the font in the menu ?

qUEJYLQ.png

Share this post


Link to post
Share on other sites
On 13.6.2016 at 9:41 PM, Mannyfresh15 said:

You're badass! all those problems have been taken care of thanks to you (:

Now I just got into a little problem setting up a picture as a background will make overlapping controls not work check my example below

$Pic1 = GUICtrlCreatePic(@TempDir & "\Samplepic.jpg", 10, 0, 460, 119, $SS_NOTIFY,$GUI_WS_EX_PARENTDRAG)
;GuiCtrlSetState(-1,$GUI_DISABLE) If I uncomment this others controls will work but drag will not. ):

 I don't wanna sound like if I'm getting advantage of you but I really would like to get some help on this because I have no problem with regular GUI but I really want to use Metro GUIs and you know you're the expert. (: 

 

Try this:

#NoTrayIcon
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <MsgBoxConstants.au3>
#include <Timers.au3>
#include <Sound.au3>
#include <MetroGUI_UDF.au3>

;!Highly recommended for improved overall performance and responsiveness of the GUI effects etc.! (after compiling):
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so /rm /pe

;Required if you want High DPI scaling enabled. (Also requries _Metro_EnableHighDPIScaling())
#AutoIt3Wrapper_Res_HiDpi=y

$Checked = False
$timer = ""
$RED = 1
$sec = @SEC
$Tiempo = ""
$Alarm = "C:\Users\Admin\Downloads\BOMB_SIREN-BOMB_SIREN-247265934.wav" ;Replace this with your own .wav file. you already knew this what the heck

; Setting Time Variables
$5m = 300000
$10m = 600000
$15m = 900250
$30m = 1800500
$45m = 2700750
$1h = 3601000

InetGet("http://imgur.com/download/C5CE14x/", @TempDir & "\Samplepic.jpg")

;=======================================================================Creating the GUI===============================================================================
;Set Theme
_SetTheme("DarkBlue") ;See MetroThemes.au3 for selectable themes or to add more

;Enable high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp.
_Metro_EnableHighDPIScaling() ; Note: Requries "#AutoIt3Wrapper_Res_HiDpi=y" for compiling. To see visible changes without compiling, you have to disable dpi scaling in compatibility settings of Autoit3.exe

;Create resizable Metro GUI
$GLOBAL_MAIN_GUI = _Metro_CreateGUI("My app", 484, 209, 255, 124, False)

$Pic1 = GUICtrlCreatePic(@TempDir & "\Samplepic.jpg", 10, 0, 460, 119, 0, $GUI_WS_EX_PARENTDRAG)

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

;Add/create control buttons to the gui
$Control_Buttons = _Metro_AddControlButtons(True, False, True, 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]
GUICtrlSetTip($GUI_CLOSE_BUTTON, "Close")
$GUI_MAXIMIZE_BUTTON = $Control_Buttons[1]
;GUICtrlSetTip($GUI_MAXIMIZE_BUTTON , "Minimizar")
$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]
GUICtrlSetTip($GUI_MENU_BUTTON, "Menu")
;======================================================================================================================================================================


;Create  Buttons
$Button1 = _Metro_CreateButton("start", 206, 177, 75, 25)
$Button2 = _Metro_CreateButton("Abort", 380, 177, 75, 25)

;Create Toggle
$Toggle1 = _Metro_CreateToggle("Alarm", 10, 147, 120, 34)
GUICtrlSetTip($Toggle1, "On/Off")

#Region ### START Koda GUI section ### Form=
$Label1 = GUICtrlCreateLabel("My Timer", 45, 119, 366, 33, $SS_CENTER, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetColor($Label1, 0xFFFFFF)
GUICtrlSetFont(-1, 16, 0, 0, "Impact")

; Create a combobox control.
$idComboBox = GUICtrlCreateCombo("Select Time", 110, 181, 90, 21)
GUICtrlSetTip(-1, "Select Time")
; Add additional items to the combobox.
GUICtrlSetData($idComboBox, "5 Minutes|10 Minutes|15 Minutes|30 Minutes|45 Minutes|1 Hour", "Select Time")
;
$Label2 = GUICtrlCreateLabel("How much Time?", 4, 183, 100, 25, $SS_CENTER, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetColor(-1, 0xFFFFFF)
$Inputtimer = GUICtrlCreateInput("00:00:00", 380, 147, 75, 20, BitOR($SS_CENTER, $ES_READONLY))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;~ GUIRegisterMsg(0x0201, "INTERNAL_WM_LBUTTONDOWN")

While 1
    _Metro_HoverCheck_Loop($GLOBAL_MAIN_GUI)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_PRIMARYDOWN
            DllCall("user32.dll", "int", "ReleaseCapture")
            DllCall("user32.dll", "long", "SendMessage", "hwnd", $GLOBAL_MAIN_GUI, "int", 0x00A1, "int", 2, "int", 0)
        Case $Button1
            startTimer()
        Case $Button2
            Exit
        Case $GUI_CLOSE_BUTTON
            ExitLoop
            Exit
        Case $GUI_MINIMIZE_BUTTON
            GUISetState(@SW_MINIMIZE)
        Case $Toggle1
            If _Metro_ToggleIsChecked($Toggle1) Then
                _Metro_ToggleUnCheck($Toggle1)
                $Checked = False
            Else
                _Metro_ToggleCheck($Toggle1)
                $Checked = True
            EndIf

        Case $GUI_MENU_BUTTON
            Local $MenuSelect = _Metro_MenuStart($GLOBAL_MAIN_GUI, $GUI_MENU_BUTTON, 150, $MenuButtonsArray) ; Opens the metro Menu. See decleration of $MenuButtonsArray above.
            Switch $MenuSelect ;Above function returns the index number of the 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)
                    Exit

            EndSwitch

    EndSwitch
WEnd

Func startTimer()

    $Comboread = GUICtrlRead($idComboBox, 0)
    If $Comboread = 0 Then
        MsgBox($MB_SYSTEMMODAL, "Warning ", "You Haven't Selected Any Time", 10)
        Return
    Else
        If $Comboread = "5 Minutes" Then $Tiempo = $5m
        If $Comboread = "10 Minutes" Then $Tiempo = $10m
        If $Comboread = "15 Minutes" Then $Tiempo = $15m
        If $Comboread = "30 Minutes" Then $Tiempo = $30m
        If $Comboread = "45 Minutes" Then $Tiempo = $45m
        If $Comboread = "1 Hour" Then $Tiempo = $1h
        ;setting warning labels
        $lbl_text = GUICtrlCreateLabel("Attention!", 180, 149, 80, 17, $SS_CENTER, $GUI_WS_EX_PARENTDRAG)
        ;GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
        GUICtrlSetColor($lbl_text, 0xff0000) ; Red
        GUICtrlSetFont($lbl_text, 9, 700)
        ;
        $lbl_text2 = GUICtrlCreateLabel("Timer will stop in:", 250, 150, 125, 20, $SS_CENTER, $GUI_WS_EX_PARENTDRAG)
        ;GUICtrlSetResizing(-1, )
        GUICtrlSetColor(-1, 0xFFFFFF)
        ; call ("startTimer2 ")
    EndIf

    ;Checking if timer is greater than 0
    If TimerDiff($timer) > 0 Then
        $timer = TimerInit()
    EndIf

    While (TimerDiff($timer) < $Tiempo)
        ;Setting Toggle
        _Metro_HoverCheck_Loop($GLOBAL_MAIN_GUI) ;To make sure that the hover effects still work
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $Toggle1
                If _Metro_ToggleIsChecked($Toggle1) Then
                    _Metro_ToggleUnCheck($Toggle1)
                    $Checked = False
                Else
                    _Metro_ToggleCheck($Toggle1)
                    $Checked = True
                EndIf
            Case $GUI_MINIMIZE_BUTTON
                GUISetState(@SW_MINIMIZE)
            Case $Button2
                ExitLoop
            Case $GUI_CLOSE_BUTTON
                Exit
        EndSwitch

        $seconds = TimerDiff($timer) / 1000
        $diff = $seconds - ($Tiempo / 1000)
        ;
        $minutes = Int($diff / 60)
        $secondsRem = $diff - ($minutes * 60)
        ;
        $hours = Int($minutes / 60)
        $minutes = $minutes - ($hours * 60)

        ;
        $hours = $hours * -1
        $minutes = $minutes * -1
        $secondsRem = $secondsRem * -1

        $time = StringFormat("%02d", $hours) & ":" & StringFormat("%02d", $minutes) & ":" & StringFormat("%02d", $secondsRem)
        ;
        GUICtrlSetData($Inputtimer, $time)

        ;Checks if timer is higher than 3mins and If toggle is on plays Sound
        If TimerDiff($timer) > $Tiempo - 180000 And $Checked = True Then _SoundPlay($Alarm, 0) ;MsgBox(0,"Aviso","Alarma",5)

        ;Checks if timer is higher than 3mins and If toggle is off checked stops Sound

        If TimerDiff($timer) > $Tiempo - 180000 And $Checked = False Then _SoundStop($Alarm)

        ; Blinking Text

        If @SEC <> $sec Then
            $sec = @SEC
            If $RED Then
                GUICtrlSetColor($lbl_text, 0xffffff)
            Else
                GUICtrlSetColor($lbl_text, 0xff0000)
            EndIf
            $RED = Not $RED
        EndIf

    WEnd

    $Readtimer = GUICtrlRead($Inputtimer, 0)
    If $Readtimer = "00:00:00" Then
        MsgBox($MB_ICONWARNING, "Notice", "Time is Up!", 15)
        _SoundStop($Alarm)
    Else
        _SoundStop($Alarm)
        GUICtrlSetData($Inputtimer, "00:00:00")
        GUICtrlDelete($lbl_text2)
        GUICtrlDelete($lbl_text)
    EndIf

EndFunc   ;==>startTimer

 

12 hours ago, pndhcm280- said:

How can i change the font in the menu ?

qUEJYLQ.png

I forgot to add that option, i will add it with the next update. Just open the MetroGUI_UDF.au3 file and change the "$Font = ":

Func _Internal_CreateMButton($Text, $Left, $Top, $Width, $Height, $BG_Color = $GUIThemeColor, $Font_Color = $FontThemeColor, $Font = "Arial", $Fontsize = 9, $FontStyle = 1, $FrameColor = "0xFFFFFF")

You can change a lot of things in the UDF file, for some things i don't want to add an option as it makes it too complicated to set 10 parameters to create a simple button etc.

1 person likes this

Share this post


Link to post
Share on other sites
11 minutes ago, BBs19 said:

 

Try this:

#NoTrayIcon
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <MsgBoxConstants.au3>
#include <Timers.au3>
#include <Sound.au3>
#include <MetroGUI_UDF.au3>

;!Highly recommended for improved overall performance and responsiveness of the GUI effects etc.! (after compiling):
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so /rm /pe

;Required if you want High DPI scaling enabled. (Also requries _Metro_EnableHighDPIScaling())
#AutoIt3Wrapper_Res_HiDpi=y

$Checked = False
$timer = ""
$RED = 1
$sec = @SEC
$Tiempo = ""
$Alarm = "C:\Users\Admin\Downloads\BOMB_SIREN-BOMB_SIREN-247265934.wav" ;Replace this with your own .wav file. you already knew this what the heck

; Setting Time Variables
$5m = 300000
$10m = 600000
$15m = 900250
$30m = 1800500
$45m = 2700750
$1h = 3601000

InetGet("http://imgur.com/download/C5CE14x/", @TempDir & "\Samplepic.jpg")

;=======================================================================Creating the GUI===============================================================================
;Set Theme
_SetTheme("DarkBlue") ;See MetroThemes.au3 for selectable themes or to add more

;Enable high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp.
_Metro_EnableHighDPIScaling() ; Note: Requries "#AutoIt3Wrapper_Res_HiDpi=y" for compiling. To see visible changes without compiling, you have to disable dpi scaling in compatibility settings of Autoit3.exe

;Create resizable Metro GUI
$GLOBAL_MAIN_GUI = _Metro_CreateGUI("My app", 484, 209, 255, 124, False)

$Pic1 = GUICtrlCreatePic(@TempDir & "\Samplepic.jpg", 10, 0, 460, 119, 0, $GUI_WS_EX_PARENTDRAG)

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

;Add/create control buttons to the gui
$Control_Buttons = _Metro_AddControlButtons(True, False, True, 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]
GUICtrlSetTip($GUI_CLOSE_BUTTON, "Close")
$GUI_MAXIMIZE_BUTTON = $Control_Buttons[1]
;GUICtrlSetTip($GUI_MAXIMIZE_BUTTON , "Minimizar")
$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]
GUICtrlSetTip($GUI_MENU_BUTTON, "Menu")
;======================================================================================================================================================================


;Create  Buttons
$Button1 = _Metro_CreateButton("start", 206, 177, 75, 25)
$Button2 = _Metro_CreateButton("Abort", 380, 177, 75, 25)

;Create Toggle
$Toggle1 = _Metro_CreateToggle("Alarm", 10, 147, 120, 34)
GUICtrlSetTip($Toggle1, "On/Off")

#Region ### START Koda GUI section ### Form=
$Label1 = GUICtrlCreateLabel("My Timer", 45, 119, 366, 33, $SS_CENTER, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetColor($Label1, 0xFFFFFF)
GUICtrlSetFont(-1, 16, 0, 0, "Impact")

; Create a combobox control.
$idComboBox = GUICtrlCreateCombo("Select Time", 110, 181, 90, 21)
GUICtrlSetTip(-1, "Select Time")
; Add additional items to the combobox.
GUICtrlSetData($idComboBox, "5 Minutes|10 Minutes|15 Minutes|30 Minutes|45 Minutes|1 Hour", "Select Time")
;
$Label2 = GUICtrlCreateLabel("How much Time?", 4, 183, 100, 25, $SS_CENTER, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetColor(-1, 0xFFFFFF)
$Inputtimer = GUICtrlCreateInput("00:00:00", 380, 147, 75, 20, BitOR($SS_CENTER, $ES_READONLY))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;~ GUIRegisterMsg(0x0201, "INTERNAL_WM_LBUTTONDOWN")

While 1
    _Metro_HoverCheck_Loop($GLOBAL_MAIN_GUI)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_PRIMARYDOWN
            DllCall("user32.dll", "int", "ReleaseCapture")
            DllCall("user32.dll", "long", "SendMessage", "hwnd", $GLOBAL_MAIN_GUI, "int", 0x00A1, "int", 2, "int", 0)
        Case $Button1
            startTimer()
        Case $Button2
            Exit
        Case $GUI_CLOSE_BUTTON
            ExitLoop
            Exit
        Case $GUI_MINIMIZE_BUTTON
            GUISetState(@SW_MINIMIZE)
        Case $Toggle1
            If _Metro_ToggleIsChecked($Toggle1) Then
                _Metro_ToggleUnCheck($Toggle1)
                $Checked = False
            Else
                _Metro_ToggleCheck($Toggle1)
                $Checked = True
            EndIf

        Case $GUI_MENU_BUTTON
            Local $MenuSelect = _Metro_MenuStart($GLOBAL_MAIN_GUI, $GUI_MENU_BUTTON, 150, $MenuButtonsArray) ; Opens the metro Menu. See decleration of $MenuButtonsArray above.
            Switch $MenuSelect ;Above function returns the index number of the 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)
                    Exit

            EndSwitch

    EndSwitch
WEnd

Func startTimer()

    $Comboread = GUICtrlRead($idComboBox, 0)
    If $Comboread = 0 Then
        MsgBox($MB_SYSTEMMODAL, "Warning ", "You Haven't Selected Any Time", 10)
        Return
    Else
        If $Comboread = "5 Minutes" Then $Tiempo = $5m
        If $Comboread = "10 Minutes" Then $Tiempo = $10m
        If $Comboread = "15 Minutes" Then $Tiempo = $15m
        If $Comboread = "30 Minutes" Then $Tiempo = $30m
        If $Comboread = "45 Minutes" Then $Tiempo = $45m
        If $Comboread = "1 Hour" Then $Tiempo = $1h
        ;setting warning labels
        $lbl_text = GUICtrlCreateLabel("Attention!", 180, 149, 80, 17, $SS_CENTER, $GUI_WS_EX_PARENTDRAG)
        ;GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
        GUICtrlSetColor($lbl_text, 0xff0000) ; Red
        GUICtrlSetFont($lbl_text, 9, 700)
        ;
        $lbl_text2 = GUICtrlCreateLabel("Timer will stop in:", 250, 150, 125, 20, $SS_CENTER, $GUI_WS_EX_PARENTDRAG)
        ;GUICtrlSetResizing(-1, )
        GUICtrlSetColor(-1, 0xFFFFFF)
        ; call ("startTimer2 ")
    EndIf

    ;Checking if timer is greater than 0
    If TimerDiff($timer) > 0 Then
        $timer = TimerInit()
    EndIf

    While (TimerDiff($timer) < $Tiempo)
        ;Setting Toggle
        _Metro_HoverCheck_Loop($GLOBAL_MAIN_GUI) ;To make sure that the hover effects still work
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $Toggle1
                If _Metro_ToggleIsChecked($Toggle1) Then
                    _Metro_ToggleUnCheck($Toggle1)
                    $Checked = False
                Else
                    _Metro_ToggleCheck($Toggle1)
                    $Checked = True
                EndIf
            Case $GUI_MINIMIZE_BUTTON
                GUISetState(@SW_MINIMIZE)
            Case $Button2
                ExitLoop
            Case $GUI_CLOSE_BUTTON
                Exit
        EndSwitch

        $seconds = TimerDiff($timer) / 1000
        $diff = $seconds - ($Tiempo / 1000)
        ;
        $minutes = Int($diff / 60)
        $secondsRem = $diff - ($minutes * 60)
        ;
        $hours = Int($minutes / 60)
        $minutes = $minutes - ($hours * 60)

        ;
        $hours = $hours * -1
        $minutes = $minutes * -1
        $secondsRem = $secondsRem * -1

        $time = StringFormat("%02d", $hours) & ":" & StringFormat("%02d", $minutes) & ":" & StringFormat("%02d", $secondsRem)
        ;
        GUICtrlSetData($Inputtimer, $time)

        ;Checks if timer is higher than 3mins and If toggle is on plays Sound
        If TimerDiff($timer) > $Tiempo - 180000 And $Checked = True Then _SoundPlay($Alarm, 0) ;MsgBox(0,"Aviso","Alarma",5)

        ;Checks if timer is higher than 3mins and If toggle is off checked stops Sound

        If TimerDiff($timer) > $Tiempo - 180000 And $Checked = False Then _SoundStop($Alarm)

        ; Blinking Text

        If @SEC <> $sec Then
            $sec = @SEC
            If $RED Then
                GUICtrlSetColor($lbl_text, 0xffffff)
            Else
                GUICtrlSetColor($lbl_text, 0xff0000)
            EndIf
            $RED = Not $RED
        EndIf

    WEnd

    $Readtimer = GUICtrlRead($Inputtimer, 0)
    If $Readtimer = "00:00:00" Then
        MsgBox($MB_ICONWARNING, "Notice", "Time is Up!", 15)
        _SoundStop($Alarm)
    Else
        _SoundStop($Alarm)
        GUICtrlSetData($Inputtimer, "00:00:00")
        GUICtrlDelete($lbl_text2)
        GUICtrlDelete($lbl_text)
    EndIf

EndFunc   ;==>startTimer

 

 

 

Once again you're badass... It worked like a charm!  Man, you really know what you're doing... Thanks for everything.

Share this post


Link to post
Share on other sites

#75 ·  Posted (edited)

@BBs19 I found something that can be considered a bug in some cases: if you set the $AllowResize option to false when creating a GUI and then use the _GUI_DragAndResizeUpdate it will override the $AllowResize option to true, in some scenarios this may not be intended.

Other bug is that when you do a WinMove() on the just created GUI changing its size before you call GUISetState(@SW_SHOW) the white border is drawn with the old size of the window (please see attached picture)

Thanks!

Regards

error gui.JPG

Edited by KarlosTHG
Added new bug

Share this post


Link to post
Share on other sites

First of all I love this UDF !

One question: what about Combo controls ?

 

Share this post


Link to post
Share on other sites
20 hours ago, KarlosTHG said:

@BBs19 I found something that can be considered a bug in some cases: if you set the $AllowResize option to false when creating a GUI and then use the _GUI_DragAndResizeUpdate it will override the $AllowResize option to true, in some scenarios this may not be intended.

Other bug is that when you do a WinMove() on the just created GUI changing its size before you call GUISetState(@SW_SHOW) the white border is drawn with the old size of the window (please see attached picture)

Thanks!

Regards

Hi, as the name says, the function is intended for resize and drag, therefore i don't know why you would use it if you set $AllowResize to false. I didn't add a seperate function to enable drag only, but i can sure do that if that is what you were trying to do. 

The other one I can't explain, because i don't know how WinMove works in Windows and why it is not resizing the border correctly if the window is not set visible first. But I don't know why it would be a problem... If you set the size/pos while creating, then u won't have the problem. You can also use GUISetState(@SW_HIDE) first, then resize and then set @SW_SHOW. 

 

7 hours ago, t0nZ said:

First of all I love this UDF !

One question: what about Combo controls ?

 

That is too much work man :D I think it would be possible, but it wouldn't be 100% a modern style, as it requires scrollbars and those look bad on older Windows versions. Creating a custom scrollbar is not on my todo list...

Besides that, imo comboboxes look pretty modern on Windows 8 and above. 

 

Share this post


Link to post
Share on other sites

#78 ·  Posted (edited)

OK got it.

It's true, actually the combobox is not much used in windows 10, there are a few examples with a very small number of items, I have counted a maximum of seven items and without scrollbars, maybe Microsoft has abandoned scrollbars in comboboxes ?

autoplayhero.png

Maybe you can think a combobox limited to ten items and without scrollbars, only an idea I can survive without....:sweating:

Anyway thank you for the good job.

Edited by t0nZ

Share this post


Link to post
Share on other sites

hi @BBs19, I'm still working with your awesome UDF, and found some things:

  1. The window cannot be minimized by clicking it on the taskbar as other windows do.
  2. When you try to assign a color to a button background you can not use the hex value directly, it is necessary to pass it as a string, I just found this by reviewing the code.

Thanks man!

Share this post


Link to post
Share on other sites
5 hours ago, KarlosTHG said:

hi @BBs19, I'm still working with your awesome UDF, and found some things:

  1. The window cannot be minimized by clicking it on the taskbar as other windows do.
  2. When you try to assign a color to a button background you can not use the hex value directly, it is necessary to pass it as a string, I just found this by reviewing the code.

Thanks man!

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.

Share this post


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

  • Similar Content

    • davidacrozier
      By davidacrozier
      Hello all ~
      I am running an autoit script on Windows 10 inside VMware Workstation 12 Pro version 12.5.2.  Technically I am remoting into ESXi which has a Domain Controller (DC), WebServer, FilServer, Windows 10, etc.  Using the GUI (i.e. running explorer.exe) I am able to open several different folders successfully.  The desktop, documents, USB external all open without issue.  The network share opening gives me issues.  Whenever I attempt to open \\filserver\users\user\sharedfolder I get the documents folder instead.  I understand that the documents folder is the default for explorer.  I have also attempted to use the letter drive mapped to the network share (Z:) and receive the same result.  When I run this script on Windows 10 alone without  the VM or the ESXi I am able to open the network share without problems.  I have tried to use the net use command to designate a letter M: to the network share folder prior to running the script.  This did not work for me.  
      One additional avenue I think might work is to use the systreeview321 and _GUICtrlTreeView_FindItem to step through the tree looking for the network share.  Once found,  double click on it and see if that opens the shared network folder.  I can click inside the VM with my mouse on the network share and it opens just fine.  Not sure if running up against GUI issues, or permission issues, or what?
      Thanks in advance,
      Davida Crozier
      TestNetworkShare.au3
      This script is a subset of a much larger program, but it illustrates what I am dealing with.

    • MrMajorThorburn
      By MrMajorThorburn
      Using sample code:
      #include <MsgBoxConstants.au3> ; Find a pure red pixel in the range 0,0-20,300
      Local $aCoord = PixelSearch(0, 0, 20, 300, 0xFF0000)
      If Not @error Then
          MsgBox($MB_SYSTEMMODAL, "", "X and Y are: " & $aCoord[0] & "," & $aCoord[1])
      Else
          MsgBox($MB_SYSTEMMODAL, "", "Pure Not Found")
      EndIf ; Find a pure red pixel or a red pixel within 10 shades variations of pure red
      $aCoord = PixelSearch(0, 0, 20, 300, 0xFF0000, 10)
      If Not @error Then
          MsgBox($MB_SYSTEMMODAL, "", "X and Y are: " & $aCoord[0] & "," & $aCoord[1])
      Else
          MsgBox($MB_SYSTEMMODAL, "", "Variant Not Found")
      EndIf   and the attached screenshot which has Pure Red (FF0000) in one icon in the area being searched. Would someone please check this out for me?
    • Miliardsto
      By Miliardsto
      Hello Im using Metro UDF and there is a code when menu panel is shown by clicking on menu button.
       
      And what I want I want make instead  Case $GUI_MENU_BUTTON, this $MenuSelect[1].. Case
      While 1 $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_MINIMIZE_BUTTON GUISetState(@SW_MINIMIZE, $Form1) Case $GUI_MENU_BUTTON ;Create an Array containing menu button names Local $MenuButtonsArray[5] = ["Themes Demo", "Settings", "About", "Contact", "Exit"] ; Open the metro Menu. See decleration of $MenuButtonsArray above. Local $MenuSelect = _Metro_MenuStart($Form1, 150, $MenuButtonsArray) Switch $MenuSelect ;Above function returns the index number of the selected button from the provided buttons array. Case "0" ConsoleWrite("Returned 0 = Starting themes demo. Please note that the window border colors are not updated during this demo." & @CRLF) ;_ThemesDemo() Case "1" ConsoleWrite("Returned 1 = Settings button clicked." & @CRLF) Case "2" ConsoleWrite("Returned 2 = About button clicked." & @CRLF) Case "3" ConsoleWrite("Returned 3 = Contact button clicked." & @CRLF) Case "4" ConsoleWrite("Returned 4 = Exit button clicked." & @CRLF) _Metro_GUIDelete($Form1) Exit EndSwitch WEnd I tried something like this what I found on forum but not work
      ;~ Case Else ;~ For $i = 0 To $MenuSelect ;~ ;MsgBox("","",$liczba) ;~ ;MsgBox("","",$MenuSelect) ;~ If $MenuSelect == "1" Then ;~ ;If $MenuSelect[$i] = "0" Then ;~ ConsoleWrite("Returned 1 = Settings button clicked." & @CRLF) ;~ ;EndIf ;~ Elseif $MenuSelect == "2" Then ;~ ConsoleWrite("Returned 2" & @CRLF) ;~ ExitLoop ;~ EndIf ;~ Next  
    • keelaji
      By keelaji
      Hello,
      first of all i searched in the forum but i didn't found any solution to my problem.
      I am using windows 10.
      I made a script that is supposed to change the title to the active window, resize it to the smallest size possible (should be around 800 x 600) and move to (0, 0).
      I can change the title but i fail to do the other 2 tasks.
      i use wingettitle [active] copied from the F1 help tool (and this works), i i put the title in a variable and than i use
      winsettitle ($variable, "one") (this works too)
      winmove ("one", 0, 0, 800, 600) (doesn't do anything)
      i also tried
      local $x = winget ( "one")
      msgbox (0, "", $x) (i get a completely white box so i suppose winget can't have any data about my window ??)
      any suggestion ?
    • spuuunit
      By spuuunit
      I have a script that autostart with Windows, and sometimes some of my code is skipped. My script takes long pauses, so it's not that the script "goes too fast". This is my script for now:
      TraySetIcon("C:\Portables\AutoIt\_\icon.ico") AutoItSetOption("WinTitleMatchMode", 2) Run("C:\Portables\Key Manager\keymanager.exe") WinActivate("ATNSOFT Key Manager v") WinWaitActive("ATNSOFT Key Manager v") WinMove("ATNSOFT Key Manager v", "", 650, 200, 600, 800) Sleep(500) $pos = MouseGetPos() MouseClick("left", 1220, 210, 1, 100) MouseMove($pos[0], $pos[1], 100) Run("C:\Portables\foobar2000\foobar2000.exe") $version = 298 For $i = 0 To 99 Step 1 $path = "C:\Users\spunit\AppData\Local\Discord\app-0.0." & $version + $i & "\Discord.exe" If FileExists($path) Then Run($path) ExitLoop EndIf Next Run("C:\Portables\Firefox\FirefoxPortable.exe") Sleep(10000) WinMove("- Mozilla Firefox", "", 205, 0, 1214, 1047) Sleep(100) MouseClick("left", 1300, 15, 1, 10) Sleep(100) MouseClick("left", 1130, 275, 1, 10) Sleep(100) MouseClick("left", 930, 105, 1, 10) Sleep(100) Send("#{m}") Sometimes it skips to click and move mouse right after Key Manager starts. Almost always it skips everything after the last run.

      This type of script were never an issue with Windows 7... Any thoughts?