Jump to content
BBs19

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

Recommended Posts

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

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

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

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

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

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: 

 

Share this post


Link to post
Share on other sites

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

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

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

Share this post


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

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

Share this post


Link to post
Share on other sites

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

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

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

    • By rdaneelol
      I have a strange behavior in an Autoit program.  
      The program works perfectly in the original environment I created the program for - for Windows 7 and Office  2010.
      My workplace is migrating to Windows 10 with Office 2016.  When I run this program in that new environment,  the code actually executes without any errors, however, the excel process which was opened to read a spreadsheet/workbook does not close while the program is running.  If you exit the program, the excel process ends at that point...
      I could ignore this behavior - one little excel process hanging out there is not going to kill anything, however - it just bugs me !
      While troubleshooting the issue, I placed a number of error checks after the excel close - and the close actually reports that it is successful. 
      I tried a few varieties of closing the excel process, and none of the methods tried seemed to actually work as well at the one in my code - the only downside being that it has to wait until the program finishes to actually close.
      Any ideas on why an excel close would hang until program exit ?
       
      Local $oExcel = _Excel_Open(False, False, False, False, True) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Local $oWorkbook = _Excel_BookOpen($oExcel, $sUserRoleMenuXLS, False, true ) If @error Then     MsgBox($MB_SYSTEMMODAL, "Excel UDF", "Error opening workbook '" & $sUserRoleMenuXLS & @CRLF & "@error = " & @error & ", @extended = " & @extended)     _Excel_Close($oExcel, False, False)  Exit EndIf ;  this section will find the user id in the first 3 columns of the user/menu spreadsheet, and if it finds it - returns the value stored in the cell 2 locations to the right... With $oExcel.ActiveSheet.Range("A:C").Find (@UserName)     $Match = .Find (@UserName)     If (Not IsObj($Match)) or (stringlen($Match.Offset(0, 2).value) = 0)    Then         MsgBox($MB_SYSTEMMODAL, 'UIPLauncher Error', 'No Menu assigned for user - Contact Support.') ; Display a warning if the script isn't compiled or the file doesn't exist.         ;_Excel_BookClose($oWorkbook, False)         _Excel_Close($oExcel, false, false)         Exit     Else         Local  $cResult = $Match.Offset(0, 2).value     EndIf EndWith $oWorkbook.Saved = True _Excel_BookClose($oWorkbook, False) _Excel_Close($oExcel, false, false) ;close does not seem to work on windows 10 and office 2016  
    • 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. 
×
×
  • Create New...