Jump to content
BBs19

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

Recommended Posts

BBs19
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
Mannyfresh15
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
BBs19
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
Mannyfresh15
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
Mannyfresh15

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
BBs19
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
Mannyfresh15
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
BBs19
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
Dreamfire

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
BBs19
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
Mannyfresh15
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
pndhcm280-

How can i change the font in the menu ?

qUEJYLQ.png

Share this post


Link to post
Share on other sites
BBs19
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.

  • Like 1

Share this post


Link to post
Share on other sites
Mannyfresh15
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
KarlosTHG

@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
t0nZ

First of all I love this UDF !

One question: what about Combo controls ?

 

Share this post


Link to post
Share on other sites
BBs19
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
t0nZ

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
KarlosTHG

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

    • Skeletor
      By Skeletor
      Hi Virtual People, 
      I'm trying to lock my screen in Windows 10 but to no avail. 
      Has Windows 10 forbidden this feature? 
      Send("#l") Above code does not work. Even sending Ctrl Alt Del does not work nor as an Admin. 
      Note: I want to lock my screen, not log off. Thanks for been kind.
       
    • astrionn
      By astrionn
      Hi Guys,
       
      I`m trying to record with my webcam in 5s intervalls and do some stuff between starting to record and stoping.
      I took code from here: https://www.autoitscript.com/forum/topic/27925-webcam-example/
      and took what looked relevant to me.
      I use 3 different files:
       Is called WMS.au3 and contains all the constants for the dll calls is called rec.au3 and does all necessary dll calls to start a webcam recording to a file Is called stopcam.exe and does the dll calls to stop recording into a file WMS.au3  :
      $WM_CAP_START = 0x400 $WM_CAP_UNICODE_START = $WM_CAP_START +100 $WM_CAP_PAL_SAVEA = $WM_CAP_START + 81 $WM_CAP_PAL_SAVEW = $WM_CAP_UNICODE_START + 81 $WM_CAP_UNICODE_END = $WM_CAP_PAL_SAVEW $WM_CAP_ABORT = $WM_CAP_START + 69 $WM_CAP_DLG_VIDEOCOMPRESSION = $WM_CAP_START + 46 $WM_CAP_DLG_VIDEODISPLAY = $WM_CAP_START + 43 $WM_CAP_DLG_VIDEOFORMAT = $WM_CAP_START + 41 $WM_CAP_DLG_VIDEOSOURCE = $WM_CAP_START + 42 $WM_CAP_DRIVER_CONNECT = $WM_CAP_START + 10 $WM_CAP_DRIVER_DISCONNECT = $WM_CAP_START + 11 $WM_CAP_DRIVER_GET_CAPS = $WM_CAP_START + 14 $WM_CAP_DRIVER_GET_NAMEA = $WM_CAP_START + 12 $WM_CAP_DRIVER_GET_NAMEW = $WM_CAP_UNICODE_START + 12 $WM_CAP_DRIVER_GET_VERSIONA = $WM_CAP_START + 13 $WM_CAP_DRIVER_GET_VERSIONW = $WM_CAP_UNICODE_START + 13 $WM_CAP_EDIT_COPY = $WM_CAP_START + 30 $WM_CAP_END = $WM_CAP_UNICODE_END $WM_CAP_FILE_ALLOCATE = $WM_CAP_START + 22 $WM_CAP_FILE_GET_CAPTURE_FILEA = $WM_CAP_START + 21 $WM_CAP_FILE_GET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 21 $WM_CAP_FILE_SAVEASA = $WM_CAP_START + 23 $WM_CAP_FILE_SAVEASW = $WM_CAP_UNICODE_START + 23 $WM_CAP_FILE_SAVEDIBA = $WM_CAP_START + 25 $WM_CAP_FILE_SAVEDIBW = $WM_CAP_UNICODE_START + 25 $WM_CAP_FILE_SET_CAPTURE_FILEA = $WM_CAP_START + 20 $WM_CAP_FILE_SET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 20 $WM_CAP_FILE_SET_INFOCHUNK = $WM_CAP_START + 24 $WM_CAP_GET_AUDIOFORMAT = $WM_CAP_START + 36 $WM_CAP_GET_CAPSTREAMPTR = $WM_CAP_START + 1 $WM_CAP_GET_MCI_DEVICEA = $WM_CAP_START + 67 $WM_CAP_GET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 67 $WM_CAP_GET_SEQUENCE_SETUP = $WM_CAP_START + 65 $WM_CAP_GET_STATUS = $WM_CAP_START + 54 $WM_CAP_GET_USER_DATA = $WM_CAP_START + 8 $WM_CAP_GET_VIDEOFORMAT = $WM_CAP_START + 44 $WM_CAP_GRAB_FRAME = $WM_CAP_START + 60 $WM_CAP_GRAB_FRAME_NOSTOP = $WM_CAP_START + 61 $WM_CAP_PAL_AUTOCREATE = $WM_CAP_START + 83 $WM_CAP_PAL_MANUALCREATE = $WM_CAP_START + 84 $WM_CAP_PAL_OPENA = $WM_CAP_START + 80 $WM_CAP_PAL_OPENW = $WM_CAP_UNICODE_START + 80 $WM_CAP_PAL_PASTE = $WM_CAP_START + 82 $WM_CAP_SEQUENCE = $WM_CAP_START + 62 $WM_CAP_SEQUENCE_NOFILE = $WM_CAP_START + 63 $WM_CAP_SET_AUDIOFORMAT = $WM_CAP_START + 35 $WM_CAP_SET_CALLBACK_CAPCONTROL = $WM_CAP_START + 85 $WM_CAP_SET_CALLBACK_ERRORA = $WM_CAP_START + 2 $WM_CAP_SET_CALLBACK_ERRORW = $WM_CAP_UNICODE_START + 2 $WM_CAP_SET_CALLBACK_FRAME = $WM_CAP_START + 5 $WM_CAP_SET_CALLBACK_STATUSA = $WM_CAP_START + 3 $WM_CAP_SET_CALLBACK_STATUSW = $WM_CAP_UNICODE_START + 3 $WM_CAP_SET_CALLBACK_VIDEOSTREAM = $WM_CAP_START + 6 $WM_CAP_SET_CALLBACK_WAVESTREAM = $WM_CAP_START + 7 $WM_CAP_SET_CALLBACK_YIELD = $WM_CAP_START + 4 $WM_CAP_SET_MCI_DEVICEA = $WM_CAP_START + 66 $WM_CAP_SET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 66 $WM_CAP_SET_OVERLAY = $WM_CAP_START + 51 $WM_CAP_SET_PREVIEW = $WM_CAP_START + 50 $WM_CAP_SET_PREVIEWRATE = $WM_CAP_START + 52 $WM_CAP_SET_SCALE = $WM_CAP_START + 53 $WM_CAP_SET_SCROLL = $WM_CAP_START + 55 $WM_CAP_SET_SEQUENCE_SETUP = $WM_CAP_START + 64 $WM_CAP_SET_USER_DATA = $WM_CAP_START + 9 $WM_CAP_SET_VIDEOFORMAT = $WM_CAP_START + 45 $WM_CAP_SINGLE_FRAME = $WM_CAP_START + 72 $WM_CAP_SINGLE_FRAME_CLOSE = $WM_CAP_START + 71 $WM_CAP_SINGLE_FRAME_OPEN = $WM_CAP_START + 70 $WM_CAP_STOP = $WM_CAP_START + 68 rec.au3  :
       
      #include <WMS.au3> #include <GUIConstants.au3> if not FileExists(@ScriptDir&"\vid\"&string(@MON)&"\"&string(@mday)) Then DirCreate(@ScriptDir&"\vid\"&"\"&string(@MON)&"\"&string(@mday)) EndIf $moviefile = @ScriptDir&"\vid"&"\"&string(@MON)&"\"&string(@mday)&"\test.avi" $avi = DllOpen("avicap32.dll") $user = DllOpen("user32.dll") FileWrite(@scriptdir&"\clop.clop",$user) $Main = GUICreate("Camera",350,270) $moviefile=@ScriptDir&"\test.avi" $cap = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD,$WS_VISIBLE), "int", 15, "int", 15, "int", 320, "int", 240, "hwnd", $Main, "int", 1) FileWrite(@scriptdir&"\clip.clip",$cap[0]) run(@scriptdir&"\stopcam.exe") DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_CONNECT, "int", 0, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_SCALE, "int", 1, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_OVERLAY, "int", 1, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEW, "int", 1, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEWRATE, "int", 1, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_FILE_SET_CAPTURE_FILEA, "int", 0, "str", $moviefile) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SEQUENCE, "int", 0, "int", 0) Stopcam.exe is the compiled version of this:
      #include "WMS.au3" #include <GUIConstants.au3> $cap = Int(FileRead(@scriptdir&"\clip.clip")) $user = int(fileread(@scriptdir&"\clop.clop")) Sleep(10000) DllCall($user, "int", "SendMessage", "hWnd", $cap, "int", $WM_CAP_STOP, "int", 0, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap, "int", $WM_CAP_END, "int", 0, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap, "int", $WM_CAP_DRIVER_DISCONNECT, "int", 0, "int", 0) DllClose($user) FileDelete(@scriptdir&"\clip.clip") FileDelete(@scriptdir&"\clop.clop")  
      Unfortunately this is not working as I thought it would be working.
      Does someone see what I´m doing wrong?
      It should record the webcam for about 10 seconds ( a little less) and save that to an .avi file.
      It does not stop the recording , I have to stop the process manually...
      Secondly, which confuses me more is that it creates the test.avi not in the location is specified in the script... its stored in the ScriptDir for whatever reason haha
      I hope you can help me
       
      ~HappyCoding
    • Daydreamer067
      By Daydreamer067
      Hi
      in windows 10 i create a new desktop.
      I want to run a script in this desktop, for exemple Mouseclick("left",x,y)
      I want the script to work in that desktop while i switch to the primary desktop.
      So far autoit clicks on the active desktop.
      Is there a way to make it run only on the other desktop ?
       
      Thank you for your response.
    • codingislife
      By codingislife
      Hi everyone, 
      I'm new to the autoit world and am trying to do something a little complicated and am having trouble developing a solution. My OS after reimaging comes up with two operating system choices during boot up, I'd like to delete the incorrect OS. I have noticed that the default OS is always the correct OS. My issue is I need a way to find the OS identifier before I can delete. I know that I  can use bcdedit to find this but it changes every time and it needs to be the correct identifier (i.e. not the Default or bootmgr). If someone knows of a way to parse through the output of bcdedit to find the identifier that would be greatly appreciated. Here is an example of what I am trying to do:
      https://scottiestech.info/2016/07/03/remove-the-choose-an-operating-system-message-when-starting-your-computer/
    • PramodR
      By PramodR
      Hello,
      i am new to AUTO IT development , I would like one help to read value from a POP up.
      i am able to read below values using inspect tool , information given below, I tried to create a script to read value but that does not help. any help is appreciated.
      Available Controls
      POPUP window Controls
      Auto Id = "UpdateNow_Btn"
      Name = Update Now
      Invoke - Button Control
      Below Controls i get when i move inspector tool to the text which i need to read. i need to read the text Name . Currently with my code i get only blank text 
      Auto Id = timeOutLb
      ClassName = TextBlock
      LegacyIAccess = GetName
      Name  = Read Value for Name
       
      My code.
       
×