Jump to content

Recommended Posts

Posted
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.

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
Posted
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. 

Posted
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.

 

Posted
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")


 

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
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
Posted

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.

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
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
Posted
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.

Posted
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.

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
Posted
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. 

 

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
  • 2 weeks later...
Posted

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!

Posted
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.

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
×
×
  • Create New...