Jump to content
BBs19

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

Recommended Posts

KarlosTHG
16 hours ago, BBs19 said:

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

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

Understood, makes sense.

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

  

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


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

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

 

Thanks!

Edited by KarlosTHG

Share this post


Link to post
Share on other sites
RWBaker

Running Version: MetroUDF-V4.0.1 with Windows 10

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

Could you look into this?

Thanks,

RWBaker

Radio Demo.au3

Edited by RWBaker

RW Baker

Share this post


Link to post
Share on other sites
Mentis

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

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

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

gui.au3

Edited by Mentis

Share this post


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

Running Version: MetroUDF-V4.0.1 with Windows 10

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

Could you look into this?

Thanks,

RWBaker

Radio Demo.au3

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

 

 

On 30.6.2016 at 4:18 PM, KarlosTHG said:

Understood, makes sense.

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

  

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


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

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

 

Thanks!

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

 

 

16 hours ago, Mentis said:

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

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

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

gui.au3

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

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

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

Share this post


Link to post
Share on other sites
Mentis

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

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

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

Share this post


Link to post
Share on other sites
PratikV

Hi BBs19, Thank you for the MetroUI. 

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

Thank you very much for the wonderful work.

Share this post


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

Hi BBs19, Thank you for the MetroUI. 

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

Thank you very much for the wonderful work.

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

Share this post


Link to post
Share on other sites
hawk63

Thank you for this great UDF.

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

Share this post


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

Thank you for this great UDF.

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

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

 

On 8.7.2016 at 3:16 PM, PratikV said:

Hi BBs19, Thank you for the MetroUI. 

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

Thank you very much for the wonderful work.

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

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

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

Edited by BBs19

Share this post


Link to post
Share on other sites
BBs19

Version 4.3 - Changelog - 13.07.2016

Bugfixes:

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

Improvements:

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

New features:

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

 

Download: 

 

  • Like 2

Share this post


Link to post
Share on other sites
cookiemonster

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

My script is:

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

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

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

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

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

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

GUISetState(@SW_SHOW)

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

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


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

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

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

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

 

Share this post


Link to post
Share on other sites
nobbitry

Hi cookiemonster, 

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

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

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

Regards

Share this post


Link to post
Share on other sites
RepublicCommando

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

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

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

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

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

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

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

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

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

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

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

 AutoIt Version: 3.3.14.2
 Author:         Jon/~RepComm

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

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

#include "App.au3"

Opt ("MustDeclareVars", 1)

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

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

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

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

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

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

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

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

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

App.au3:

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

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

Global $STATE = False
Global $nMsg

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

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

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

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

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

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

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

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

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

    GUISetState(@SW_SHOW)
EndFunc

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

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

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

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

Edited by RepublicCommando
Spelling, no reason to double post, and I can't count..
  • Like 1

Share this post


Link to post
Share on other sites
BBs19
On 29.7.2016 at 7:33 PM, cookiemonster said:

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

My script is:

 

 

On 29.7.2016 at 9:11 PM, nobbitry said:

Hi cookiemonster, 

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

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

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

Regards

 

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

Share this post


Link to post
Share on other sites
youtuber

my trouble resizing Progress

http://prntscr.com/c2jsc1

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

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

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

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

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

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

GUISetState(@SW_SHOW)

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


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

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

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

    EndSwitch
WEnd

 

 

Share this post


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

my trouble resizing Progress

http://prntscr.com/c2jsc1

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

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

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

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

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

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

GUISetState(@SW_SHOW)

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


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

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

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

    EndSwitch
WEnd

 

 

Set the proper resizing option for the progress: 

GUICtrlSetResizing($Progress1[0],  1)

 

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

  • Like 1

Share this post


Link to post
Share on other sites
Wingens

Hi,


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

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

Hope you can help me.

Forum-Post.zip

Edited by Wingens

Share this post


Link to post
Share on other sites
Carm01

Is it just me , maybe I am missing something, but in the example on the line:

$Form1 = _Metro_CreateGUI("Example", 500, 300, -1, -1, True)

Should not "Example" show in the title bar?

Thanks

Share this post


Link to post
Share on other sites
KillTrot

I need the possibility to change the text of a metro button please.

Very nice UDF:)

Share this post


Link to post
Share on other sites
nobbitry

Hi @KillTrot

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

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


_SetTheme("DarkGreen")
_Metro_EnableHighDPIScaling()

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

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

GUISetState(@SW_SHOW)

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

 

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

    • faustf
      By faustf
      hi guys
      i have a script  like this,  in windows 7 work perfect , in windows 10 not  work  , some one can explain me  why ??'
      #include <Array.au3> #include <MsgBoxConstants.au3> Global $aGPathFoto= FileReadToArray (@ScriptDir & "\TEMP\PathFoto.txt") Local $ctrl = 0 While 1 Local $hWnd = WinWait("[CLASS:#32770]", "", 10) If WinExists("[CLASS:#32770]") Then If $ctrl < 2 Then ControlSend($hWnd, "Choose File to Upload", "[CLASS:Edit; INSTANCE:1]", $aGPathFoto[0]&"{Enter}") Exit $ctrl += 1 Else ExitLoop EndIf EndIf WEnd $aGpathfoto = C:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg
    • 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/
×