Jump to content
BBs19

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

Recommended Posts

4 hours ago, coffeeturtle said:

Understood. No worries. Everything seems to be working well.

Just was curious: What would be the best way to get Transparency to work with the Metro GUI?

On Windows 10, this works fine: _WinAPI_DwmEnableBlurBehindWindow10($Form1, True)/#include <_WinAPI_DwmEnableBlurBehindWindow10.au3>

However, this does not work with Windows 7. The old GUI Create does have a flag for transparent layers, but not sure if there is a Metro equivalent?

Thanks again!

The transparent flag is not the same as the blur effect you can get on Windows 10. I don't know any of other way to get the same effect on Windows 7.

Share this post


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

The transparent flag is not the same as the blur effect you can get on Windows 10. I don't know any of other way to get the same effect on Windows 7.

That is true. Just plain old transparency (maybe 10%) would suffice, but as you said, there may not be a way.  Thanks though.

Share this post


Link to post
Share on other sites
On 2/21/2017 at 9:31 AM, coffeeturtle said:

Understood. No worries. Everything seems to be working well.

Just was curious: What would be the best way to get Transparency to work with the Metro GUI?

On Windows 10, this works fine: _WinAPI_DwmEnableBlurBehindWindow10($Form1, True)/#include <_WinAPI_DwmEnableBlurBehindWindow10.au3>

However, this does not work with Windows 7. The old GUI Create does have a flag for transparent layers, but not sure if there is a Metro equivalent?

Thanks again!

Did you try: WinSetTrans ( "title", "text", transparency )

Share this post


Link to post
Share on other sites
On 9/12/2016 at 0:12 PM, Carm01 said:

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

I am noticing this as well.  The Title does not seem to show in the top bar as is intended?  Is this a bug... or is there something else we need to do to put the title in the top bar?

 

I also noticed that the "X" button seems to be dimmed out.  The other buttons seem to be whiter.  The close button still functions normally though.

 

What is the difference between the Maximize button and Full Screen buttons?  If I comment out the Maximize button... it causes the Minimize button to stop working properly.  It just quickly flashes as if it did a minimize and restore.  I just don't see a point in having both a Full Screen and Maximize button at the same time.  Are there different uses for it?

Thanks!  The work on this UDF is awesome!  I can't wait to implement it into my programs. 

 

 

Oh... one more question... Does this work on Windows Vista, XP and earlier NT systems?  Or will I need to make sure I implement code for earlier systems?

Edited by Proph

Share this post


Link to post
Share on other sites

To fix the Title issue I went ahead and made this change to script...

MetroGUI_UDF.au3

Under This:

If $AllowResize Then
    DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme
    $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), -1, $ParentGUI)
    _Metro_SetGUIOption($GUI_Return, True, True, $Width, $Height)
    DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4))
Else
   DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ;Adds compatibility for Windows 7 Basic theme
    $GUI_Return = GUICreate($Title, $Width, $Height, $Left, $Top, -1, -1, $ParentGUI)
    _Metro_SetGUIOption($GUI_Return, False, False, $Width, $Height)
    DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", BitOR(1, 2, 4))
EndIf

Add this:

GUICtrlCreateLabel($Title, 54, 7)
GUICtrlSetColor(-1, $FontThemeColor)
GUICtrlSetFont(-1, 8.5, 400, 0, "Arial", 5)

 

Hope this helps someone until the UDF is updated with something better. ;)

Edited by Proph

Share this post


Link to post
Share on other sites
On 6.3.2017 at 7:53 PM, Proph said:

I am noticing this as well.  The Title does not seem to show in the top bar as is intended?  Is this a bug... or is there something else we need to do to put the title in the top bar?

The title is not supposed to be visible within the GUI, so that you have more place on your GUI to customize it. However I can add an extra option in the next versions.

On 6.3.2017 at 7:53 PM, Proph said:

I also noticed that the "X" button seems to be dimmed out.  The other buttons seem to be whiter.  The close button still functions normally though.

Make sure you enable the HighDPI support in the Script and compile the script or disable the compatibility scaling for the .exe file of Autoit. This should make it look sharper and not look dimmed.

On 6.3.2017 at 7:53 PM, Proph said:

What is the difference between the Maximize button and Full Screen buttons?  If I comment out the Maximize button... it causes the Minimize button to stop working properly.  It just quickly flashes as if it did a minimize and restore.  I just don't see a point in having both a Full Screen and Maximize button at the same time.  Are there different uses for it?

The name already tells it :) The fullscreen button is supposed to make the GUI get in front of everything on your desktop. Unfortunately MS again changed something with a Windows 10 update and fu**ed it up as the taskbar stays in front now. Many programs don't work in Fullscreen mode anymore since this update. Only popup windows work in fullscreen mode now. I will try to implement a workaround for the next version.

Ps.: If you comment out the maximize button, then you also have to comment out the restore button, otherwise it won't work as both belong together.

 

On 6.3.2017 at 7:53 PM, Proph said:

Oh... one more question... Does this work on Windows Vista, XP and earlier NT systems?  Or will I need to make sure I implement code for earlier systems?

I can't say as i haven't tested it. I also don't know anyone who still uses XP, therefore I never got any reports if it works or not.

 

On 15.3.2017 at 0:17 PM, Andre82 said:

Hi,

i try to tabbing from Button to Button, but it dont work.

Any Idea?

Thank you in advance for any help on this.

Hi, yes that doesn't work unfortunately. All i know is that it is probably complicated and requires a lot of time and motivation to get it working with such pictures :)

 

Share this post


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

The title is not supposed to be visible within the GUI, so that you have more place on your GUI to customize it. However I can add an extra option in the next versions.

Make sure you enable the HighDPI support in the Script and compile the script or disable the compatibility scaling for the .exe file of Autoit. This should make it look sharper and not look dimmed.

The name already tells it :) The fullscreen button is supposed to make the GUI get in front of everything on your desktop. Unfortunately MS again changed something with a Windows 10 update and fu**ed it up as the taskbar stays in front now. Many programs don't work in Fullscreen mode anymore since this update. Only popup windows work in fullscreen mode now. I will try to implement a workaround for the next version.

Ps.: If you comment out the maximize button, then you also have to comment out the restore button, otherwise it won't work as both belong together.

 

I can't say as i haven't tested it. I also don't know anyone who still uses XP, therefore I never got any reports if it works or not.

 

Hi, yes that doesn't work unfortunately. All i know is that it is probably complicated and requires a lot of time and motivation to get it working with such pictures :)

 

I figured out my issue with commenting out the maximize button. You are right... I wasn't commenting out the restore button. ;)

I have tested this on XP and Vista and it does all seem to work. :)  I don't use XP... but I know there are still some stubborn users out there that do. ;)  I just want to make sure my program is compatible.  For some odd reason I wasn't able to get HighDPI to work with my script.  When I enable it my program will not open when it is compiled... but it does open when it is run through scite un-compiled for some reason.  Odd... but it seems to look fine without it for now. The dim X button might just be my eyes thinking it looks dim. It looks fine though, so not a big deal.

 

Thanks for the work on this.  It's really a great UDF.

Share this post


Link to post
Share on other sites

Radio is too how to be small font?

$Radio1 = _Metro_CreateRadio("1", "Yes", 424, 40, 185, 30)
GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
$Radio2 = _Metro_CreateRadio("1", "No", 424, 90, 185, 30)
GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
_Metro_RadioCheck("1", $Radio1)

 

Share this post


Link to post
Share on other sites
On 2/18/2017 at 5:24 AM, BBs19 said:

Thanks :)

What do you mean with include GUICtrlSetResizing for labels?

TV-Show-Manager is opensource, so you can check out the code any time. But I would suggest you wait, as the code was written very bad back then, I am rewriting the program from scratch to look similar to Netflix. Here is a small demo: Picture It will take some time to finish, as I am not really motivated to work on it at the moment :) 

 

Hey @BBs19 !!  Just was wondering if your newer version of TV-Show-Manager is still coming along? When it is finished, will the Check for Updates work?

Thanks again!

Share this post


Link to post
Share on other sites
On 23.3.2017 at 9:11 PM, youtuber said:

Radio is too how to be small font?

$Radio1 = _Metro_CreateRadio("1", "Yes", 424, 40, 185, 30)
GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
$Radio2 = _Metro_CreateRadio("1", "No", 424, 90, 185, 30)
GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
_Metro_RadioCheck("1", $Radio1)

 

_Metro_CreateRadio("1", "Yes", 424, 40, 185, 30,  $GUIThemeColor, $FontThemeColor,"Segoe UI", "14")

 

3 hours ago, coffeeturtle said:

Hey @BBs19 !!  Just was wondering if your newer version of TV-Show-Manager is still coming along? When it is finished, will the Check for Updates work?

Thanks again!

Hi, thanks for reminding me. I had not enough time and motivation to work on it yet. I would like to finish my plans for MetroGUI UDF and use it in TV-Show-Manager V5.  I am lacking the motivation and time that I had before that allowed me to finish such things within 2-3 days :sweating: I ran into some compatibility problems on Windows 7 and lower, with some of the effects I used which caused a lot of time to be wasted and was a set back for the project..

I will for sure finish it as I have put a lot of work in the current state of it, it is just a question of time.  And yes, the check for updates should work. 

Edited by BBs19

Share this post


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

_Metro_CreateRadio("1", "Yes", 424, 40, 185, 30,  $GUIThemeColor, $FontThemeColor,"Segoe UI", "14")

 

Hi, thanks for reminding me. I had not enough time and motivation to work on it yet. I would like to finish my plans for MetroGUI UDF and use it in TV-Show-Manager V5.  I am lacking the motivation and time that I had before that allowed me to finish such things within 2-3 days :sweating: I ran into some compatibility problems on Windows 7 and lower, with some of the effects I used which caused a lot of time to be wasted and was a set back for the project..

I will for sure finish it as I have put a lot of work in the current state of it, it is just a question of time.  And yes, the check for updates should work. 

Thank you for both the MetroGui UDF and TV-Show-Manager. Both work great in the current state, but I would love to see what you come up with next!

Although I am all for backwards compatibility when it comes to software, there are times when you might have to cut the cord (or maybe split a project's development). Win8 and greater can move forward with all the goodies, while Win7 and lower keeps the core functions that work well.  My $.02. :-)

Share this post


Link to post
Share on other sites

Is there any way for me to make a Metro InputBox? I scrolled through the functions list and I couldn't find anything there. I've got pretty much everything up and running for the program I'm making for myself, if anyone could point me in the right direction that would be great.

 

Thanks OP for making a beautiful GUI for us :)

Share this post


Link to post
Share on other sites

I see in the UDF there is nothing for Tabs? It would be awesome to add the

GUICtrlCreateTabItem

Into the MetroUI.  

Share this post


Link to post
Share on other sites

The last version is great.

Is there any way to add a picture to a button ?

Edit :
Finally it's good. I managed to change the function to do what I wanted.
Here is the modified function for those who are interested (it allows to add an icon and to select if the effect of hovering brightens or darkens the background color).

; #FUNCTION# ====================================================================================================================
; Name ..........: _Metro_CreateButtonModEx
; Description ...: Creates Windows 10 style buttons with a frame around. Hovering changes the button color to a darker color.
; Syntax ........: _Metro_CreateButtonModEx($Text, $Left, $Top, $Width, $Height[, $BG_Color = $ButtonBKColor[,
;                  $Font_Color = $ButtonTextColor[, $Font = "Arial"[, $Fontsize = 12.5[, $FontStyle = 1[,
;                  $FrameColor = "0x1B1B1B"[, $Darker = False[, $Icon = ""]]]]]]]])
; Parameters ....: $Text                - Text of the button.
;                  $Left                - Left pos.
;                  $Top                 - Top pos.
;                  $Width               - Width.
;                  $Height              - Height.
;                  $BG_Color            - [optional] Button background color. Default is $ButtonBKColor.
;                  $Font_Color          - [optional] Font colore. Default is $ButtonTextColor.
;                  $Font                - [optional] Font. Default is "Arial".
;                  $Fontsize            - [optional] Fontsize. Default is 12.5.
;                  $FontStyle           - [optional] Fontstyle. Default is 1.
;                  $FrameColor          - [optional] Button frame color. Default is "0x1B1B1B".
;                  $Darker              - [optional] Hover effect darker for light button. Default is false.
;                  $Icon                - [optional] Icon for the button. Default is none.
; Return values .: Handle to the button.
; Example .......: _Metro_CreateButtonModEx("Button 1",50,50,120,34)
; ===============================================================================================================================

Func _Metro_CreateButtonModEx($Text, $Left, $Top, $Width, $Height, $BG_Color = $ButtonBKColor, $Font_Color = $ButtonTextColor, $Font = "Arial", $Fontsize = 11, $FontStyle = 1, $FrameColor = "0x1B1B1B", $Darker = False, $Icon = "")
    Local $Button_Array[16]

    Local $btnDPI = _HighDPICheck()
    If $HIGHDPI_SUPPORT Then
        $Left = Round($Left * $gDPI)
        $Top = Round($Top * $gDPI)
        $Width = Round($Width * $gDPI)
        $Height = Round($Height * $gDPI)
    Else
        $Fontsize = ($Fontsize / $Font_DPI_Ratio)
    EndIf

    $Button_Array[1] = False ; Set hover OFF
    $Button_Array[3] = "2" ; Type
    $Button_Array[15] = GetCurrentGUI()

    ;Calculate Framesize
    Local $FrameSize = Round(2 * $btnDPI)
    If Not (Mod($FrameSize, 2) = 0) Then $FrameSize = $FrameSize - 1

    ;Set Colors
    $BG_Color = "0xFF" & Hex($BG_Color, 6)
    $Font_Color = "0xFF" & Hex($Font_Color, 6)
    $FrameColor = "0xFF" & Hex($FrameColor, 6)
    Local $Brush_BTN_FontColor = _GDIPlus_BrushCreateSolid($Font_Color)
    Local $Pen_BTN_FrameHoverColor = _GDIPlus_PenCreate($FrameColor, $FrameSize)
    Local $Pen_BTN_FrameHoverColorDis = _GDIPlus_PenCreate(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"), $FrameSize)
    Local $Brush_BTN_FontColorDis = _GDIPlus_BrushCreateSolid(StringReplace(_AlterBrightness($Font_Color, -30), "0x", "0xFF"))

    ;Create Button graphics
    Local $Button_Graphic1 = _GDIPlusGraphic_Create($Width, $Height, $BG_Color, 0, 5) ;Default
    If $Darker Then
        Local $Button_Graphic2 = _GDIPlusGraphic_Create($Width, $Height, StringReplace(_AlterBrightness($BG_Color, -10), "0x", "0xFF"), 0, 5) ;Hover
    Else
        Local $Button_Graphic2 = _GDIPlusGraphic_Create($Width, $Height, StringReplace(_AlterBrightness($BG_Color, 25), "0x", "0xFF"), 0, 5) ;Hover
    EndIf
    Local $Button_Graphic3 = _GDIPlusGraphic_Create($Width, $Height, $BG_Color, 0, 5) ;Disabled

    ;Create font, Set font options
    Local $hFormat = _GDIPlus_StringFormatCreate(), $hFamily = _GDIPlus_FontFamilyCreate($Font), $hFont = _GDIPlus_FontCreate($hFamily, $Fontsize, $FontStyle)
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, $Width, $Height)
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    _GDIPlus_StringFormatSetLineAlign($hFormat, 1)

    ;Draw button text
    _GDIPlus_GraphicsDrawStringEx($Button_Graphic1[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor)
    _GDIPlus_GraphicsDrawStringEx($Button_Graphic2[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColor)
    _GDIPlus_GraphicsDrawStringEx($Button_Graphic3[0], $Text, $hFont, $tLayout, $hFormat, $Brush_BTN_FontColorDis)

    ;Add Icon
    If  $Icon <> "" Then
        Local $Button_Icon = _GDIPlus_BitmapCreateFromFile($Icon)
        Local $Button_Icon_dpi = _GDIPlus_ImageScale($Button_Icon, $gdpi, $gdpi, 7)
        Local $Icon_W = _GDIPlus_ImageGetWidth($Button_Icon_dpi)
        Local $Icon_H = _GDIPlus_ImageGetHeight($Button_Icon_dpi)
        _GDIPlus_GraphicsDrawImage($Button_Graphic1[0], $Button_Icon_dpi, ($Width-$Icon_W)/2, ($Height-$Icon_H)/2)
        _GDIPlus_GraphicsDrawImage($Button_Graphic2[0], $Button_Icon_dpi, ($Width-$Icon_W)/2, ($Height-$Icon_H)/2)
        _GDIPlus_GraphicsDrawImage($Button_Graphic3[0], $Button_Icon_dpi, ($Width-$Icon_W)/2, ($Height-$Icon_H)/2)
    EndIf

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

    ;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)
    _GDIPlus_PenDispose($Pen_BTN_FrameHoverColorDis)
    If  $Icon <> "" Then
        _GDIPlus_BitmapDispose($Button_Icon)
        _GDIPlus_BitmapDispose($Button_Icon_dpi)
    EndIf

    ;Set graphic and return Bitmap handle
    $Button_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height)
    $Button_Array[5] = _GDIPlusGraphic_CreateBitmapHandle($Button_Array[0], $Button_Graphic1)
    $Button_Array[6] = _GDIPlusGraphic_CreateBitmapHandle($Button_Array[0], $Button_Graphic2, False)
    $Button_Array[7] = _GDIPlusGraphic_CreateBitmapHandle($Button_Array[0], $Button_Graphic3, False)

    ;Set GUI Resizing
    GUICtrlSetResizing($Button_Array[0], 768)

    _Internal_AddHoverItem($Button_Array)
    Return $Button_Array[0]

EndFunc   ;==>_Metro_CreateButtonEx

 

Edited by hawk63

Share this post


Link to post
Share on other sites

Im sorry for probably what is such a simple answer, but how can I delete a control thats been made? I made a progress bar with metro and now I can't figure out how to delete that progress bar without deleting the entire GUI. Sorry for the question, might be because its late that I can't figure it out. 

 

Just figured out that the handle was in an array, sorry to waste time. :)

Edited by joboy2k

Share this post


Link to post
Share on other sites

It happens joboy2k.. I've had that before.. Especially on my  one post.... You talk about the issue then you leave it for a few days.... Answer hits you when you don't think about it.

Share this post


Link to post
Share on other sites

Version 5.0 - Changelog - 03.09.2017

New features:

  • Hover effects, minimize,maximize,restore and other GUI effects are now working natively, there is no need to call any function in a loop.
    • This also allows the hover effects to work if the main script is paused due to "Sleep, Msgbox etc."
    • The hover effects now work slightly faster and create less CPU usage, however the startup time of the main script is slightly increased. Thanks to @binhnx for his SSCtrlHover UDF.
  • Maximize, Minimize, Fullscreen and Restore buttons now work natively, meaning you don't need to set actions for them manually. 
    • If you prefer handling the buttons manually, then you can disable this by setting "$ControlBtnsAutoMode = False"
  • Added _Metro_CreateButtonEx2 -> Creates a slightly rounded button without a frame around. Hovering changes the button color to a lighter color.
  • Added _Metro_CreateCheckboxEx2 -> Creates a modern round checkbox.
  • Added _Metro_CreateRadioEx -> Creates a metro style radio with colored checkmark.
  • Added "_Metro_RightClickMenu" an easy to use rightclick menu. You can use this with listviews or anything else.
    • Check out the example for a demo of the rightclick menu and how to implement it. -> Rightclick on Button3 to show the menu.
  • Added multiple new themes with flat colors and updated the old themes.
    • Check out the example for a demo with all themes by pressing the menu button -> Themes Demo

Improvements:

  • You can now delete all controls that have hover effects(buttons, checkboxes etc.) using GUICtrlDelete($ControlHandle). This will also automatically release all resources and remove the control from the global array.
  • Many other optimizations,changes and bugfixes.

 

Download UDF with example:

 

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