Jump to content
BBs19

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

Recommended Posts

On 21.2.2016 at 11:01 PM, legend said:

can you show an example of how to have multiple gui windows, so if you click a button,

it will create a new gui, and when you X it, then it removes the GUI again.

I tried that, but it will make the orginal gui stock, and not able to be moved

 

You can use this example. To call it, just use this:

_GUIDisable($Form1, 0, 30);For better visibility of the second GUI
_SecondGUI()
_GUIDisable($Form1)
Func _SecondGUI()
    $Form2 = _Metro_CreateGUI("Example 2", 500, 300, -1, -1, True, True)

    ;Set variables
    $GUI_HOVER_REG2 = $Form2[1]
    $GUI_CLOSE_BUTTON_GUI2 = $Form2[2]
    $Form2 = $Form2[0]
    GUISetState(@SW_SHOW)
    
    While 1
        _Metro_HoverCheck_Loop($GUI_HOVER_REG2, $Form2);Add hover check in loop
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON_GUI2
                _Metro_GUIDelete($GUI_HOVER_REG2, $Form2)
                _GUI_DragAndResizeUpdate($Form1);Update the first GUI to properly support drag/resize again. (Only needed if you created 2 guis with control buttons(close,minimize,maximize))
                Return 0
        EndSwitch
    WEnd
    
EndFunc   ;==>_SecondGUI

 

On 1.3.2016 at 3:33 PM, lampel said:

how can i add a text edit control (GUICtrlCreateEdit) ???

 

thanks lampel

There is no function for a metro style edit. But you can use "0" as ex-style parameter to make it look modern/flat:

$Edit1 = GUICtrlCreateEdit("", 15, 285, 430, 213, BitOR($ES_AUTOVSCROLL, $ES_READONLY, $WS_VSCROLL), 0)

 

On 8.3.2016 at 10:29 PM, legend said:

Is it really not possible to change the state of a radiobox, but only a toggle and a checkbox,

why would there even be a radiobox in the udf, if you can't check if it's selected or not 0_o

http://prntscr.com/ad909v

I never needed that before. As given in the example, I usually execute what has to be done after the user selects a radio :)

But I will update the UDF today and add that check function + example.

 

21 hours ago, nuhan said:

hi,

i want to use  MetroGUI UDF v3  in my script. I need help to create a message box using  _Metro_MsgBox. but in metro udf MsgBox  contains only one button i need two button in my message box. And also i have to run some code if user click on each button in msgbox. Please help me.

 

As written via PM, this can be done with a custom gui or by simply copying the default metro msgbox function and modifying it. If I find some time, i will try to update the message box function to support the default button types that the normal MsgBox of Autoit also supports. 

Share this post


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

 

You can use this example. To call it, just use this:

_GUIDisable($Form1, 0, 30);For better visibility of the second GUI
_SecondGUI()
_GUIDisable($Form1)
Func _SecondGUI()
    $Form2 = _Metro_CreateGUI("Example 2", 500, 300, -1, -1, True, True)

    ;Set variables
    $GUI_HOVER_REG2 = $Form2[1]
    $GUI_CLOSE_BUTTON_GUI2 = $Form2[2]
    $Form2 = $Form2[0]
    GUISetState(@SW_SHOW)
    
    While 1
        _Metro_HoverCheck_Loop($GUI_HOVER_REG2, $Form2);Add hover check in loop
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON_GUI2
                _Metro_GUIDelete($GUI_HOVER_REG2, $Form2)
                _GUI_DragAndResizeUpdate($Form1);Update the first GUI to properly support drag/resize again. (Only needed if you created 2 guis with control buttons(close,minimize,maximize))
                Return 0
        EndSwitch
    WEnd
    
EndFunc   ;==>_SecondGUI

 

There is no function for a metro style edit. But you can use "0" as ex-style parameter to make it look modern/flat:

$Edit1 = GUICtrlCreateEdit("", 15, 285, 430, 213, BitOR($ES_AUTOVSCROLL, $ES_READONLY, $WS_VSCROLL), 0)

 

I never needed that before. As given in the example, I usually execute what has to be done after the user selects a radio :)

But I will update the UDF today and add that check function + example.

 

As written via PM, this can be done with a custom gui or by simply copying the default metro msgbox function and modifying it. If I find some time, i will try to update the message box function to support the default button types that the normal MsgBox of Autoit also supports. 

Great job, thank you!

Share this post


Link to post
Share on other sites

Updated UDF to v3.5

  • Updated Metro Msgbox function to support different button combinations like the default MsgBox function in Autoit.(See Help file for the button combination flags)
  • Added function "_Metro_RadioIsChecked" due to request.
  • Changed default font to Arial because "Calibri Light" is not installed on all Windows 7 computers.
  • Updated example.

Share this post


Link to post
Share on other sites
On 5/6/2014 at 3:06 AM, BBs19 said:

Features:

  • Create modern looking borderless and resizable GUIs with control buttons (Close,Maximize/Restore,Minimize)
  • Many color schemes/themes included. See MetroThemes.au3 for more details.
  • 2 type of Windows 8/10 style buttons.
  • Metro style checkboxes, radios, toggles and progressbar.
  • All buttons, checkboxes etc. have hover effects!
  • Windows 10 style modern MsgBox.


Example(Image): 

1.png.26f122bd1cde2d6226fd0b0e22072181.p

Hover effect of the control buttons:

2.png.77d74cdc1b71db39a3050459e908cca9.p

Windows 10-Style MsgBox:

3.png.c97a5309bcec9e06fbce528a98dbb926.p

 

Example:

#NoTrayIcon
#include "MetroGUI_UDF.au3"


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

;Create resizable Metro GUI
$Form1 = _Metro_CreateGUI("Example", 500, 300, -1, -1, True, True); Returns an array, see below how to use it:

;Set a variable name for the Hover-Reg Array that contains all the needed data for the hover effects. You will be needing this for almost every action. Name it wisely.
$GUI_HOVER_REG = $Form1[1]

;Set variables for the handles of the GUI-Control buttons (Close/Maximize/Restore/Minimize)
$GUI_CLOSE_BUTTON = $Form1[2]
$GUI_MAXIMIZE_BUTTON = $Form1[3]
$GUI_RESTORE_BUTTON = $Form1[4]
$GUI_MINIMIZE_BUTTON = $Form1[5]

;Set GUI/Form handle from the _Metro_CreateGUI return array.
$Form1 = $Form1[0]
;======================================================================================================================================================================

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

;Create Checkbox
$Checkbox1 = _Metro_CreateCheckbox($GUI_HOVER_REG, "Checkbox 1", 30, 70, 125, 30)
_Metro_CheckboxCheck($GUI_HOVER_REG, $Checkbox1)

;Create 2 Radios that are assigned to Radio Group 1
$Radio1 = _Metro_CreateRadio($GUI_HOVER_REG, 1, "Radio 1", 180, 70, 100, 26)
$Radio2 = _Metro_CreateRadio($GUI_HOVER_REG, 1, "Radio 2", 180, 110, 100, 26)
_Metro_RadioCheck($GUI_HOVER_REG, 1, $Radio1)

;Create Toggle
$Toggle1 = _Metro_CreateToggle($GUI_HOVER_REG, "Toggle 1", 320, 70, 130, 22)

;Create Progressbar
$Progress1 = _Metro_CreateProgress(100, 180, 300, 26)

;Set resizing options for the controls
GUICtrlSetResizing($Button1, 768 + 8)
GUICtrlSetResizing($Button2, 768 + 8)
GUICtrlSetResizing($Checkbox1, 768 + 2 + 32)
GUICtrlSetResizing($Radio1, 768 + 2 + 32)
GUICtrlSetResizing($Radio2, 768 + 2 + 32)
GUICtrlSetResizing($Toggle1, 768 + 2 + 32)
GUICtrlSetResizing($Progress1[0], 768 + 2 + 32)


GUISetState(@SW_SHOW)


While 1
    _Metro_HoverCheck_Loop($GUI_HOVER_REG, $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($GUI_HOVER_REG, $Form1)
            Exit
        Case $GUI_MAXIMIZE_BUTTON
            GUISetState(@SW_MAXIMIZE)
        Case $GUI_RESTORE_BUTTON
            GUISetState(@SW_RESTORE)
        Case $GUI_MINIMIZE_BUTTON
            GUISetState(@SW_MINIMIZE)
            ;===================================================================================================
            
        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.", 400, 12, $Form1)
            _GUIDisable($Form1)
            
        Case $Button1
            _GUIDisable($Form1, 0, 30)
            _Metro_MsgBox(0, "Metro MsgBox Example", "Press ok to set progressbar.", 350, 13, $Form1)
            _GUIDisable($Form1)
            For $i = 0 To 85 Step +2
                Sleep(1)
                _Metro_SetProgress($Progress1, $i)
            Next
            _GUIDisable($Form1, 0, 30)
            Local $Select_YesNo = _Metro_MsgBox(4, "Metro MsgBox Example", "Select yes to create a second GUI.", 350, 13, $Form1)
            If $Select_YesNo = "Yes" Then _SecondGUI()
            _GUIDisable($Form1)
            
        Case $Toggle1
            If _Metro_ToggleIsChecked($GUI_HOVER_REG, $Toggle1) Then
                _Metro_ToggleUnCheck($GUI_HOVER_REG, $Toggle1)
                ConsoleWrite("Toggle unchecked!" & @CRLF)
            Else
                _Metro_ToggleCheck($GUI_HOVER_REG, $Toggle1)
                ConsoleWrite("Toggle checked!" & @CRLF)
            EndIf
            
        Case $Checkbox1
            If _Metro_CheckboxIsChecked($GUI_HOVER_REG, $Checkbox1) Then
                _Metro_CheckboxUnCheck($GUI_HOVER_REG, $Checkbox1)
                ConsoleWrite("Checkbox unchecked!" & @CRLF)
            Else
                _Metro_CheckboxCheck($GUI_HOVER_REG, $Checkbox1)
                ConsoleWrite("Checkbox checked!" & @CRLF)
            EndIf
            
        Case $Radio1
            _Metro_RadioCheck($GUI_HOVER_REG, 1, $Radio1)
            ConsoleWrite("Radio 1 selected!" & @CRLF)
            
        Case $Radio2
            _Metro_RadioCheck($GUI_HOVER_REG, 1, $Radio2)
            ConsoleWrite("Radio 2 selected = " & _Metro_RadioIsChecked($GUI_HOVER_REG, 1, $Radio2) & @CRLF)
    EndSwitch
WEnd



Func _SecondGUI()
    $Form2 = _Metro_CreateGUI("Example 2", 800, 600, -1, -1, True, True)

    ;Set variables for a second gui
    $GUI_HOVER_REG2 = $Form2[1]
    $GUI_CLOSE_BUTTON_GUI2 = $Form2[2]
    $Form2 = $Form2[0]
    GUISetState(@SW_SHOW)
    
    While 1
        _Metro_HoverCheck_Loop($GUI_HOVER_REG2, $Form2);Add hover check in loop
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON_GUI2
                _Metro_GUIDelete($GUI_HOVER_REG2, $Form2);Delete GUI/release resources
                _GUI_DragAndResizeUpdate($Form1);Update the first GUI to properly support drag/resize again. (Only needed if you created 2 guis with control buttons(close,minimize,maximize))
                Return 0
        EndSwitch
    WEnd
    
EndFunc   ;==>_SecondGUI

 

Credits: UEZ, for the function to create buttons with text using GDIPlus.

Changelog v3.5:

  • Updated Metro Msgbox function to support different button combinations like the default MsgBox function in Autoit.(See Help file for the button combination flags)
  • Added function "_Metro_RadioIsChecked" due to request.
  • Changed default font to Arial because "Calibri Light" is not installed on all Windows 7 computers.
  • Updated example.

 

Download UDF:

 

MetroGUI UDF v3.5.zip

hi  , when i try to use _Metro_MsgBox   error message shows - "warning: $MSGBOX_HOVER_REG: possibly used before declaration." where is the problem? Thanks in advance for your help.

Share this post


Link to post
Share on other sites

Well, same problem as above...

I check the syntax, fine... compile fine... when I run the binary compiled, returns an error of a variable used before declaration on line 11674. I already checked most includes the UDF uses, none of the files return syntax problems. It's like a dead end... sadly.

Windows 10 Pro 64 Bits here, latest version of SciTE and compiling x86 of course.

UPDATE 1:
I used Exe2Aut to decompile my script and check said line:
 

_gdiplus_fontdispose($hfont)

Still, there's no variable being used without declaration...

UPDATE 2:

Seems the progress bar functions in this UDF are not compatible with updates made in the GDIPlus, like these functions in the MetroGUI UDF:

Local $ProgressBGPen = _GDIPlus_PenCreate($Progress[5], 2)

In the GDIPlus the function doesn't receive parameters as called:
 

Func _GDIPlus_PenCreate($iARGB = 0xFF000000, $nWidth = 1, $iUnit = 2)
    Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreatePen1", "dword", $iARGB, "float", $nWidth, "int", $iUnit, "handle*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    If $aResult[0] Then Return SetError(10, $aResult[0], 0)

    Return $aResult[4]
EndFunc

The strange part, is the example script runs just fine... I'll attach my test script if anyone is kind to point out where's my stupid error.

UPDATE 3:

Well, it worked after I removed the GUI creation from inside a function, why? I really don't know... now I can't make the label show up.

UPDATE 4:

It worked okay now. Declare the variable that will handle the MetroGUI object at the start of the script with a 0 if you want different functions to handle it.

I left all the updates if someone needs the "thought process" to solve the problem.

Edited by LFCavalcanti
Update

--

"There is a way out of every box, a solution to every puzzle; it's just a matter of finding it." - Picard, Jean-Luc

Share this post


Link to post
Share on other sites

UDF V4 will be coming in the next 2 weeks :)

New features(finished already):

  • Usage of the UDF got much easier,  using/declaring a variable for GUI_HOVER_REG is no longer required and therefore it is not needed for all actions anymore.
  • Full support for high dpi screens / automated scaling of the gui and all metro controls for a sharp looking GUI with 4k screens
  • 2 new modern checkbox types
  • 2 new modern toggles
  • Control buttons with inactivity colors (to indicate that the window is inactive)
  • Hover effects now also work when the gui is inactive but visible.
  • Many bug fixes.

And some other things I planned like a Windows 10 style menu but didn't find time yet and also don't know if I can implement them.

 

Preview

 

Edited by BBs19

Share this post


Link to post
Share on other sites

Hi!

I've used your UDF on a project I'm developing...

I made some changes for two things:

  1.  Create a GUI that can me moved but not resized.
  2.  Option to create only the Minimize and Close buttons and another with all Control Buttons(as default in the UDF).

* The updated source file is attached bellow.

 

 _Metro_CreateGUI

I've changed the parameters, removing the "$AllowResize" , adding "$TypeOption" and "$ControlButtons".

See the comments:

Spoiler

; #FUNCTION# ====================================================================================================================
; Name ..........: _Metro_CreateGUI
; Description ...: Creates a borderless Metro-Style GUI
; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $TypeOption = 0[,
;                  $ControlButtons = True[, $ParentGUI = ""]]]]])
; Parameters ....: $Title               - Title of the window.
;                  $Width               - Width
;                  $Height              - Height
;                  $Left                - [optional] Left position. Default is -1.
;                  $Top                 - [optional] Top position. Default is -1.
;
;                  $TypeOption        - [optional] Borderless window that allows drag, resize and also keeps the AeroSnap functions working. Default is 0.
;                                                    0 - Popup style, no resize, move or maximize
;                                                    1 - Move but no resize or maximize, but with AeroSnap
;                                                    2 - All features with AeroSnap
;                   [NOTE]: Can only be called for one GUI. If you create a second GUI with this option, you have to call _GUI_DragAndResizeUpdate($GUI) for your previous GUI after closing the second one.
;
;                  $ControlButtons      - [optional] Adds Close,Maximize/Restore and Minimize buttons to the GUI. Default is 0.
;                                                     0 - No Control Buttons
;                                                     1 - Minimize and Close Buttons
;                                                     2 - All control Buttons
;                    [NOTE]: Remember to only implement the apropriate array references for the Hover Loop and actions.
;
;                  $ParentGUI           - [optional] Parent GUI/Window, This makes sure, there are not multiple windows of your program in the taskbar.
; Return values .: Array[6]
;                   [0] = Handle to the created GUI.
;                   [1] = Array for GUI_HOVER_REG. This is very important. Without this you won't be having working hover effects. Name the variable wisely. For example $GUI_HOVER_REG.
;                   [2] = Handle for the $GUI_CLOSE_BUTTON (Only if created with $ControlButtons = True)
;                   [3] = Handle for the $GUI_MAXIMIZE_BUTTON (Only if created with $ControlButtons = True)
;                   [4] = Handle for the $GUI_RESTORE_BUTTON (Only if created with $ControlButtons = True)
;                   [5] = Handle for the $GUI_MINIMIZE_BUTTON (Only if created with $ControlButtons = True)
; Example .......: $Form1 = _Metro_CreateGUI("Example", 500, 300, -1, -1, True, True)
; ===============================================================================================================================

I've marked the code I've changed with the Regions:
## UPDATED RESIZE ##
## UPDATED CONTROL BUTTONS CALL ##

_Metro_CreateControlButtons

Also, for simple shortage of time, I change the function "_Metro_CreateControlButtons", now there's two functions, one called "_Metro_CreateControlButtonsAll", that creates all Control Buttons and another called "_Metro_CreateControlButtonsCloseMini" that creates only the Minimize and Close buttons.

I kept the same array references across all functions, so the same array position for the minimize button is used even if the maximize is not present.

MetroGUI_UDF.au3


--

"There is a way out of every box, a solution to every puzzle; it's just a matter of finding it." - Picard, Jean-Luc

Share this post


Link to post
Share on other sites
On 4.5.2016 at 10:31 PM, LFCavalcanti said:

Hi!

I've used your UDF on a project I'm developing...

I made some changes for two things:

  1.  Create a GUI that can me moved but not resized.
  2.  Option to create only the Minimize and Close buttons and another with all Control Buttons(as default in the UDF).

* The updated source file is attached bellow.

 

 _Metro_CreateGUI

I've changed the parameters, removing the "$AllowResize" , adding "$TypeOption" and "$ControlButtons".

See the comments:

  Reveal hidden contents

; #FUNCTION# ====================================================================================================================
; Name ..........: _Metro_CreateGUI
; Description ...: Creates a borderless Metro-Style GUI
; Syntax ........: _Metro_CreateGUI($Title, $Width, $Height[, $Left = -1[, $Top = -1[, $TypeOption = 0[,
;                  $ControlButtons = True[, $ParentGUI = ""]]]]])
; Parameters ....: $Title               - Title of the window.
;                  $Width               - Width
;                  $Height              - Height
;                  $Left                - [optional] Left position. Default is -1.
;                  $Top                 - [optional] Top position. Default is -1.
;
;                  $TypeOption        - [optional] Borderless window that allows drag, resize and also keeps the AeroSnap functions working. Default is 0.
;                                                    0 - Popup style, no resize, move or maximize
;                                                    1 - Move but no resize or maximize, but with AeroSnap
;                                                    2 - All features with AeroSnap
;                   [NOTE]: Can only be called for one GUI. If you create a second GUI with this option, you have to call _GUI_DragAndResizeUpdate($GUI) for your previous GUI after closing the second one.
;
;                  $ControlButtons      - [optional] Adds Close,Maximize/Restore and Minimize buttons to the GUI. Default is 0.
;                                                     0 - No Control Buttons
;                                                     1 - Minimize and Close Buttons
;                                                     2 - All control Buttons
;                    [NOTE]: Remember to only implement the apropriate array references for the Hover Loop and actions.
;
;                  $ParentGUI           - [optional] Parent GUI/Window, This makes sure, there are not multiple windows of your program in the taskbar.
; Return values .: Array[6]
;                   [0] = Handle to the created GUI.
;                   [1] = Array for GUI_HOVER_REG. This is very important. Without this you won't be having working hover effects. Name the variable wisely. For example $GUI_HOVER_REG.
;                   [2] = Handle for the $GUI_CLOSE_BUTTON (Only if created with $ControlButtons = True)
;                   [3] = Handle for the $GUI_MAXIMIZE_BUTTON (Only if created with $ControlButtons = True)
;                   [4] = Handle for the $GUI_RESTORE_BUTTON (Only if created with $ControlButtons = True)
;                   [5] = Handle for the $GUI_MINIMIZE_BUTTON (Only if created with $ControlButtons = True)
; Example .......: $Form1 = _Metro_CreateGUI("Example", 500, 300, -1, -1, True, True)
; ===============================================================================================================================

I've marked the code I've changed with the Regions:
## UPDATED RESIZE ##
## UPDATED CONTROL BUTTONS CALL ##

_Metro_CreateControlButtons

Also, for simple shortage of time, I change the function "_Metro_CreateControlButtons", now there's two functions, one called "_Metro_CreateControlButtonsAll", that creates all Control Buttons and another called "_Metro_CreateControlButtonsCloseMini" that creates only the Minimize and Close buttons.

I kept the same array references across all functions, so the same array position for the minimize button is used even if the maximize is not present.

MetroGUI_UDF.au3

Hi, I have added an option to create the control buttons within an extra function in the upcoming UDF v4. It will automatically hide the control buttons that are not selected. You will be able to select even one button only. I will upload the new UDF after I have updated the comments in the UDF etc. I also need to check for bugs and fix them, some are really time consuming as they require lots of workarounds. I will need 2-3 days, i don't have much time at the moment.

 

Share this post


Link to post
Share on other sites
On 13/05/2016 at 7:26 PM, BBs19 said:

Hi, I have added an option to create the control buttons within an extra function in the upcoming UDF v4. It will automatically hide the control buttons that are not selected. You will be able to select even one button only. I will upload the new UDF after I have updated the comments in the UDF etc. I also need to check for bugs and fix them, some are really time consuming as they require lots of workarounds. I will need 2-3 days, i don't have much time at the moment.

 

Great!

I did these modifications to suit my needs and shared them, maybe someone wants to use as I did, maybe not.

Time is a limited resource... haha

I'm using the UDF in this: https://github.com/LFCavalcanti/intermix


--

"There is a way out of every box, a solution to every puzzle; it's just a matter of finding it." - Picard, Jean-Luc

Share this post


Link to post
Share on other sites

Changelog v4:

Note: There are many changes in this version and it will not work with the syntax used in the old v3.5 UDF.

New features:

  • Full High-DPI support for 4k screens. - Automated scaling of the gui and all buttons, checkboxes etc. created with the metro UDF style. (See example and comments on how to use)
  • Using the UDF is now easier than ever, many things have been simplified! It is also no longer required to use a HOVER_REG variable when creating buttons etc.
  • 2 new modern checkbox styles
  • 2 new modern toggle styles
  • Fullscreen GUI toggle button like in Windows 10 apps
  • Easy to use menu that slides in from left (like menus in Android and Windows 10 calculator app)
  • Added button enable/disable functions to give a button a grayed out look when it is disabled.
  • Control buttons now indicate that the window is inactive by their color

Improved:

  • Creating control buttons is now seperated from the main gui create function, this allows selecting which control buttons to create and which to hide completley.
  • Hovering over control buttons while window is inactive now also works
  • Many other small changes that I don't remember anymore :D 
  • Many bug fixes.

 

Download: 

 

Edited by BBs19

Share this post


Link to post
Share on other sites
6 hours ago, legend said:

It's a great new update :)

 

What would be really cool would be a gui editor, like a koda metro edition :D

I might try to create a very very simple one in future, but nothing like Koda. I think that would be too time consuming now :D

You can also just use KODA to create your GUI with the correct size etc. and afterwards replace the default Autoit functions with my UDF. Functions for creating buttons etc. are now mostly the same as the default Autoit functions, if not easier in some cases :) It is mostly find&replace.

Edit: Updated the function overview section in the UDF file to show all user functions ordered in categories for easy usage. I previously forgot to add the new functions to that list. You can just redownload from the same page.

Edited by BBs19

Share this post


Link to post
Share on other sites

@BBs19 this is awesome!! but in the quick review that I made I found a bug, the steps to get it are:

  1. Open the example script
  2. Click the button style 1
  3. Yes to create the second GUI
  4. Minimize the second GUI
  5. It becomes a white bar in the bottom corner without any button (I have only test it on one computer (Win7 x64, last Autoit stable version)
  6. If I press Windows+DownArrow both GUIs minimize but after restore them now the GUI 1 have the original Windows Title Bar

Other than that I love the new features.

Thanks! 

Share this post


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

@BBs19 this is awesome!! but in the quick review that I made I found a bug, the steps to get it are:

  1. Open the example script
  2. Click the button style 1
  3. Yes to create the second GUI
  4. Minimize the second GUI
  5. It becomes a white bar in the bottom corner without any button (I have only test it on one computer (Win7 x64, last Autoit stable version)
  6. If I press Windows+DownArrow both GUIs minimize but after restore them now the GUI 1 have the original Windows Title Bar

Other than that I love the new features.

Thanks! 

Hi, thanks for the report. 

My fault, creating a second GUI with control buttons and with a parent of course doesn't make sense. By setting a parent, the second gui is prevented from appearing in the taskbar as an extra window, so if you minimize it, it will appear as a small window with minimize, maximize and close buttons in Windows, but drawing of these default buttons is prevented and therefore only a white field appears.

In summary, if you have 2 GUIs with control buttons like minimize and maximize, then no parent window should be set for the second gui so it can appear in the taskbar as a second window.

 

;Local $Form2 = _Metro_CreateGUI("Example 2", 800, 600, -1, -1, True,$Form1);OLD
Local $Form2 = _Metro_CreateGUI("Example 2", 800, 600, -1, -1, True);Fixed

I found other bugs while testing on Windows 7 with 2 monitors today at work.

  • Fullscreen toggle sends the GUI only to the first monitor and not the monitor that the window is on at the moment. -> Fixed now
  • Fullscreen toggle will cause the screen to not refresh properly on Windows 7. -> Fixed now
  • Windows 7 basic theme is not compabile with the GUI, the upper corners are rounded which makes the GUI look strange. -> Workaround implemented
  • Windows 7 basic and classic theme will cause the first GUIs non-client arena(close,minimize,maximize..) to redraw again when the second gui is minimized. -> Workaround implemented
  • The upper 2 lines of the fullscreen toggle (restore) button don't look straight on all dpi sizes. - I seriously hate GDI Plus and math, i suck at both :D will check this tomorrow.
  • Starting the script from within Scite Portable version will cause hover to not work anymore. - Not sure if this is a real bug or if I can fix it without removing the newly added feature "Hovering over control buttons while window is inactive now also works".

I will update the UDF later tomorrow after properly testing at work on a Windows 7 machine.

Edited by BBs19

Share this post


Link to post
Share on other sites

Version 4.0.1 - Changelog:

Fixed bugs:

  • Fullscreen toggle sends the GUI only to the first monitor and not the monitor that the window is on at the moment.
  • Fullscreen toggle will cause the screen to not refresh properly on Windows 7. 
  • Windows 7 basic theme makes the GUI look strange with rounded corners on top.
  • Windows 7 basic and classic theme will cause the first GUIs non-client arena(controlbar) to show up when a second GUI is minimized.
  • Fullscreen toggle buttons arrow lines are not straight when using different DPI settings.
  • Starting the script from within Scite Portable version will cause hover to not work anymore.

 

Download:

 

 

Let me know if you find any other bugs :) 

Share this post


Link to post
Share on other sites

Very good progress on this project! :thumbsup:

 

 


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Oh, my! That is anxiously amazing! Just indeed what i've looked for (and tried to create something similar) so long. THANK YOU.

Share this post


Link to post
Share on other sites

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

 

Edited by Mannyfresh15

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

    • By Yodavish
      My AutoIt script works fine, for the most part, however, if it goes idle for roughly 30 minutes, it will won't be able to send data to a 3rd party application window titled, "Case #". 
      The problem lies within the function "SendFusion", it's able to see the handle for the "WinActivate" and "WinWaitActivate" (I've also tried putting in 10 seconds in the WinWaitActivate as well, doesn't work). However, if we have been idle, it will always fail to send data afterward. On what I've tried so far:
      "Send" function with the data and a {ENTER} i.e. Send($CaseTxt & "{ENTER}"), this won't even hit the enter key  ControlSetText, tried passing the handle from WinActivate, using the title "Case #" that was copied directly from the Autoit Window Info, hard coding the title, Using CLASS:WindowsForms10... always returns a 0 ControlCommand (same as above) always returns a 0 ControlGetFocus always returns a 0 ControlFocus, always returns a 0 Creating a new and simple Au3 script that just sends data to "Case #", also fails NOTE: If I close the Au3 script and just scan the data directly into the "Case #" or even type it, it works fine with no issues. I'm confused as to why it would not work after a long idle period?
      Below are the essential parts of the script, I can provide the entire thing if needed. Any suggestions would be greatly appreciated!
      #include <AutoItConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <Process.au3> #include <Misc.au3> #include <IE.au3> ;--------------------------------------------------------------- ; Only one instance can run ;--------------------------------------------------------------- If _Singleton("gross.exe", 1) = 0 Then MsgBox($MB_SYSTEMMODAL, "Warning", "Gross.exe is already running. Please exit the existing version first (check the icons in the lower right corner of your screen) before running it again.") Exit EndIf ;--------------------------------------------------------------- ; AutoIt Options ;--------------------------------------------------------------- Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Opt("WinWaitDelay", 0) ; Alters how long a script should briefly pause after a successful window-related operation. Time in milliseconds to pause (default=250). Opt("WinTextMatchMode", 1) ; Alters the method that is used to match window text during search operations. 2 = Quick mode Opt("SendKeyDelay", 0) ; Alters the length of the brief pause in between sent keystrokes. A value of 0 removes the delay completely. Time in milliseconds to pause (default=5). if ($fusionWindowTitle="NONE" or $fusionCaseNumWinTitle="NONE" or $appWindowTitle="NONE" or $winActivateTimeout="NONE" or $winCloseTimeout="NONE" or $winWaitTimeout="NONE" or $pdfViewerWidth="NONE" or $pdfViewerHeight="NONE" or $pdfViewerLeft="NONE" or $pdfViewerWindowName="NONE" or $pdfViewerExeName="NONE" or $pdfUrl="NONE" or $pdfDownloadCommand="NONE") Then Msgbox(0,"ERROR", "gross.ini is missing or does not contain all settings. Please contact Help Desk with this information") Exit -1 EndIf ;--------------------------------------------------------------- ; application settings/constants ;--------------------------------------------------------------- Global Const $[VARIABLE] = IniRead("gross.ini", "default", "[TitleOfVariable]", "NONE") Global Const $[VARIABLE] = IniRead("gross.ini", "default", "[TitleOfVariable]", "NONE") Global Const $[VARIABLE] = IniRead("gross.ini", "default", "[TitleOfVariable]", "NONE") Global Const $[VARIABLE] = IniRead("gross.ini", "default", "[TitleOfVariable]", "NONE") ;--------------------------------------------------------------- ; create the main window ;--------------------------------------------------------------- Local $mainWindow = GUICreate($appWindowTitle, 380, 190) ; create the main GUI window GUISetOnEvent($GUI_EVENT_CLOSE, "handleCloseClick") ; when the click the windows close button call handleCloseClick() WinSetOnTop($appWindowTitle, '', 1) ; Sets main GUI always on top ;--------------------------------------------------------------- ; create the controls on the main window ;--------------------------------------------------------------- Local $okButton = GUICtrlCreateButton("OK", 160, 160, 54,24) ; create OK button GUICtrlSetOnEvent($okButton, "validateInput") ; when they click ok, call handleInputProcessRequest() GUICtrlCreateLabel("Scan Input", 10, 10) ; create a label Global $inputScan = GUICtrlCreateInput("", 10,134,358) ; create the input scan box GUICtrlSetOnEvent($inputScan, "validateInput") ; when they press enter in the scan input box, call handleInputProcessRequest() GUICtrlSetState($inputScan,$GUI_FOCUS) ; automatically sets focus on the input field GUISetState(@SW_SHOW) ; main GUI loop that runs at all times ;--------------------------------------------------------------- While 1 ;---------------------------------------------------------- ; If sumatraPDF active, resets focus back to GUI ;---------------------------------------------------------- If WinActive($pdfViewerWindowName) Then consoleWrite('While Loop sumatraPDF was active' & @CRLF) setMainWindow() ;---------------------------------------------------------- ; After data sent to ProTracker, check for mismatch ; save button to trigger the event handler when clicked ;---------------------------------------------------------- ElseIf WinActive($proTrackerWindowTitle) Then $ie = _IEAttach("ProTracker") $mismatchButton = _IEGetObjByName($ie, $proTrackerMisMatchButtonId) $oEvent = ObjEvent($mismatchButton, "mismatchButton_") If @error Then setMainWindow() ;--------------------------------------------------------------------- ; If Fusion is prompting for the case #, focus back to main GUI input ; If second GUI 'Unknown' detect do nothing ;--------------------------------------------------------------------- ElseIf WinExists($fusionWindowTitle) and WinExists($fusionCaseNumWinTitle) and Not WinActive($mainWindow) and Not WinExists('Unknown Input') Then setMainWindow() EndIF ;--------------------------------------------------------------------- ; Checks if $processFlag = Done, if so, shows PDF viewer and clears ; processFlag for next iteration ;--------------------------------------------------------------------- IF WinExists($pdfViewerWindowName) and $processFlag == 'Done' Then WinSetState ($pdfViewerWindowName, '', @SW_SHOW) $processFlag = '' setMainWindow() EndIF Sleep(100) ; Sleep to reduce CPU usage WEnd Func handleInputProcessRequest($input) $processFlag = True Local $hTimer = TimerInit() consoleWrite('> handleInputProcessRequest: ' & @CRLF) Local $idInput = identifyInput($input) ; Select a proccess to run based on id input Select Case $idInput = "container" ; regex that captures only the case number $caseTxt = StringUpper(StringRegExpReplace($strippedInputData, '\??(\w*\d*-\d*|\d*).*$','$1')) If WinExists($fusionWindowTitle) and WinExists($fusionCaseNumWinTitle) Then sendProTracker(StringUpper($strippedInputData)) sendFusion($caseTxt) ; gets pdf for sumatraPDF in seperate script, since that function is the slowest Run("viewPDF.exe " & $caseTxt) ;getSumatraPDF($caseTxt) $lastCaseNum = $caseTxt Else ; Checks to make sure the previous "Container" case num is the same ; to the current Container case num, before sending to ProTracker If($lastCaseNum <> $caseTxt) Then ; If not the same case number send alert sound SoundPlay("error.wav") Else sendProTracker($strippedInputData) EndIf EndIf Case $idInput = "user" sendProTracker($strippedInputData) Case $idInput = "cassette" sendProTracker(StringUpper($strippedInputData)) Case $idInput = "unknown" selectUnknown() EndSelect Local $fDiff = TimerDiff($hTimer) $processFlag = 'Done' consoleWrite('> handleInputProcessRequest Completed Total time: ' & $fDiff & ' ' &@CRLF&@CRLF&@CRLF) EndFunc Func sendFusion($caseTxt)     Local $hTimer = TimerInit()     consoleWrite('+ sendFusion initiated: ' & $caseTxt & @CRLF)     If $caseTxt = "" Then         MsgBox(0, "Error", "Not a valid case number")     Else         ;$fusionCaseNumWinTitle = "Case #"         $retVal1 = WinActivate($fusionCaseNumWinTitle, "")         consoleWrite("ReturnValue WinActivate " & $retVal1 & @CRLF)         $retVal2 = WinWaitActive($fusionCaseNumWinTitle,"",$winActivateTimeout)         consoleWrite("ReturnValue WinWaitActive: " & $retVal2 & @CRLF)         $retVal3 = ControlSetText($fusionCaseNumWinTitle, "", "", $caseTxt)         ;$retVal3 = ControlCommand($fusionCaseNumWinTitle, "", "", "EditPaste", $caseTxt)         consoleWrite("ReturnValue ControlSetText: " & $retVal3 & @CRLF)         ;Send($caseTxt & "{ENTER}")         WinWaitClose($fusionCaseNumWinTitle, "", $winCloseTimeout)         consoleWrite('+ sendFusion WinWaitClose: ' & @CRLF)     EndIf     Local $fDiff = TimerDiff($hTimer)     ConsoleWrite('+ sendFusion Completed Total time:' & $fDiff & ' ' & @CRLF) EndFunc
      Console logs from the SciTLE
      Window (x86) Info matches the correct handle for the WinActivate and WinWaitActivate

      Window Control (x86) Info, I've tried the CLASS, the ID, also I just noticed that the "handle" in "Control" and "Window" appear to be different as well.

       
      So far the only work-around is to close down the 3rd party application and the AutoIt script, re-open them and it works all completely fine. But this is a pain for the end-user since it's all touch screen and it slows down their workflow, which they can be extremely sensitive about.
       
    • By antonioj84
      I am not able to use the $GUI_READ_EXTENDED with the  Metro UDF,  any work around ?
      Local $aPos[2] = [$Radio1, $Radio2] For $Radio In $aPos If GUICtrlRead($Radio) = $GUI_UNCHECKED Then ContinueLoop IniWrite($sGUIstate_IniFile, "Data", "POS", GUICtrlRead($Radio, $GUI_READ_EXTENDED)) ;; return the text of the menu item ExitLoop Next  
    • By taylansan
      Hello All, 
      If you're interested in the story, read below. Otherwise, just jump to the end of the post. 
      Story: 
      Sometimes my computer goes crazy with Windows update. I tried to turn it off with "services.msc", but couldn't close the it. So, I did some research online that it's triggered by Update Orchestration and Task Scheduler and Windows Update. I also checked that all three processes are triggered by svchost.exe.

      So, I tried to make a script to close this process. I found some useful functions ProcessList and _ProcessGetName using the help documents and coded something as below: 
      #include <MsgBoxConstants.au3> #include <Process.au3> Local $aProcessList = ProcessList() For $i = 1 To $aProcessList[0][0] $iPid = $aProcessList[$i][1] $sName = _ProcessGetName($iPid) MsgBox($MB_SYSTEMMODAL, "The process", "PID: " & $iPid & @CRLF & "NAME: " & $sName) If $sName = "svchost.exe" Then ;ProcessClose($iPid) ;I don't know if this is the process I want to close EndIf Next But the problem is; there are so many svchost.exe exists in the process list. I can't close all of them, some of them are essential to run Windows (well, accidentally I terminated some of them and ended up with a blue screen  
      ---------------
      Well, how can I know the process name like "Service Host: Update Orchestration" (not the scvhost)?
      It's not only with the .exe file, just to the name shown in Windows. 
    • By Yodavish
      I have this AutoIt script that works on Windows 7. However, when I test it on Windows 10, the objEvent will not execute the function it's supposed to call. So I have a webpage the script will check if it is active, then it will search if a popup button exist (elementId), if so, assign it to the event handler so that when that button is clicked, then handler function will move the focus back to the main GUI again.
      If WinActive("Website Title - Internet Explorer") Then    $ie = _IEAttach("Website Title")    $objElement= _IEGetObjById ($ie, "elementId")    local $oEvent = ObjEvent($objElement, "_MY_EVENT_HANDLER_") EndIf Func _MY_EVENT_HANDLER_onclick($oEvtObj)     msgbox(0,"Alert Window", "Button Clicked!") setMainWindow() ; sets focus back to main GUI EndFunc  
      I've verified, on Windows 10, that it does see the object element. But it will not trigger the event. Could it be related to some timing issues due to Windows 10 Internet Explorer over Windows 7 Internet Explorer? 
      Windows 7 IE version 11.0.9600.19507
      Windows 10 IE version 11.418.18362.0
      AutoIt v 3.3
       
×
×
  • Create New...