Jump to content

Recommended Posts

Posted (edited)

Anyone has minded by a way or another to create a new status of toggle button with enable / disabled ?

I mean, like Metro does

If I disable the toggle button, the border color remains the same than the theme, I'd like it to become greyed like this

Think I am not GDI+ skilled enough to get this easily :/

disable.PNG

Edited by Ebola57
  • 2 months later...
Posted

Hey!  Very cool udf.  Liking it a lot.  I did want to ask if this scenario is possible, as I can't seem to implement it.  Is it possible to create a gui where the menu is permanently expanded?  As in, the GUI shows all of the menu buttons when the GUI loads and cannot be unexpanded?  Thanks in advance. 

  • 2 months later...
Posted (edited)

Привет всем, я новичок в AutoIT, и у меня проблема. Я использую свой скрипт вместе с флажками. Я использую свой старый скрипт, и они работают. Но не могу заставить работать с MetroUDF. Я прикреплю свой старый скрипт. Извините за мой английский, я русский.

; ===============================================================================================================================
; Name ..........: MetroGUI UDF Example
; Version .......: v5.1
; Author ........: BB_19
; ===============================================================================================================================
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <String.au3>
#include <Crypt.au3>
#RequireAdmin
#NoTrayIcon

$Main = GUICreate('FNKC Pack by DiJo ver.1.1', 588, 410, 318, 213) ;рисуем главное окно
GUISetBkColor(0x000000)
GUICtrlCreatePic(@ScriptDir & '\Logo.jpg', 0, 0, 585, 500)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState()
; Внести строку и подпись
GUICtrlCreateLabel  ("HOST", 331, 335, 30, 11)
GUICtrlSetFont(8, 800, 0, "Tahoma") ;задаем стиль элементу выше
GUICtrlSetColor     (-1, 0xffffff)
GUICtrlSetBkColor   (-1, 0x000000)
$iHostName = GUICtrlCreateInput("", 362, 330, 180, 21, $ES_CENTER)
$Button1 = GUICtrlCreateButton("Ping",5, 30, 267, 43)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") ;задаем стиль элементу выше
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x545454)
GUISetState() ; Show GUI
$Button2 = GUICtrlCreateButton("Start", 360, 355, 73, 33, $BS_DEFPUSHBUTTON) ;создаем кнопку подключения
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") ;задаем стиль элементу выше
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x545454)
GUISetState() ; Show GUI)
$Checkbox1 = GUICtrlCreateCheckbox("", 275, 45, 12, 12)    ;1
GUISetState()
Local $rHostName

GUISetOnEvent($GUI_EVENT_CLOSE,"Exit1") ; If you press the X button ---> Call Function Exit1
GUICtrlSetOnEvent($Button1,"Pings") ; If Click to Button ---> Call Function Note
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2
            $rHostName = GUICtrlRead($iHostName)
            If $rHostName <> '' Then
                If GUICtrlRead($Checkbox1) = 1 Then ;отмечен чекбокс
                    RunWait(@ComSpec & ' /c C:\Windows\System32\Ping.exe ' & $rHostName & '')
                 EndIf
                 EndIf
         EndSwitch
WEnd


Func Exit1()
    Exit
EndFunc

; mandatory
While 2
    Sleep(10)
WEnd

 

Edited by DirtyJohny
This simple example)
Posted (edited)

И это мой новый скрипт. Мои кнопки работают, а флажки нет. Понятия не имею ((((

Opt("GUIOnEventMode", 1)
;!Highly recommended for improved overall performance and responsiveness of the GUI effects etc.! (after compiling):
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so /rm /pe

;YOU NEED TO EXCLUDE FOLLOWING FUNCTIONS FROM AU3STRIPPER, OTHERWISE IT WON'T WORK:
#Au3Stripper_Ignore_Funcs=_iHoverOn,_iHoverOff,_iMinBtn,_iMaxBtn,_iCloseBtn,_iRestoreBtn,_iFullscreenToggleBtn,_cHvr_CSCP_X64,_cHvr_CSCP_X86,_iControlDelete
;Please not that Au3Stripper will show errors. You can ignore them as long as you use the above Au3Stripper_Ignore_Funcs parameters.

;Required if you want High DPI scaling enabled. (Also requries _Metro_EnableHighDPIScaling())
#AutoIt3Wrapper_Res_HiDpi=y
; ===============================================================================================================================

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <String.au3>
#include <Crypt.au3>
#include "MetroGUI_UDF.au3"
#include "_GUIDisable.au3" ; For dim effects when msgbox is displayed
#include <GUIConstants.au3>
#RequireAdmin
#NoTrayIcon

;=======================================================================Creating the GUI===============================================================================
;Enable high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp.
 ; Note: Requries "#AutoIt3Wrapper_Res_HiDpi=y" for compiling. To see visible changes without compiling, you have to disable dpi scaling in compatibility settings of Autoit3.exe
;~ $OnEventMode = True

;Set Theme
_SetTheme("DirtyJohny") ;See MetroThemes.au3 for selectable themes or to add more

;Create resizable Metro GUI
$Form1 = _Metro_CreateGUI("Example", 350, 230, 318, 213, True)

;Add/create control buttons to the GUI
$Control_Buttons = _Metro_AddControlButtons(True, True, True, True, 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.)
;All control buttons like maximize, minimize, fullscreen etc. (except the menu button) work natively. You can use these variables to handle the clicks manually, if you do so, then make sure set $ControlBtnsAutoMode = False
$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]
;======================================================================================================================================================================
Func _GUIEvent_ControlButtons()
    Switch @GUI_CtrlId
        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, $Form1)
        Case $GUI_MINIMIZE_BUTTON
            GUISetState(@SW_MINIMIZE, $Form1)
        Case $GUI_RESTORE_BUTTON
            GUISetState(@SW_RESTORE, $Form1)
                    ; Open the metro Menu. See decleration of $MenuButtonsArray above.

      EndSwitch
EndFunc   ;==>_GUIEvent_ControlButtons
;Create  Buttons

$Button1 = _Metro_CreateButton("Ping",15, 35, 267, 40)
GUISetState()
$Button2 = _Metro_CreateButton("Start", 125, 120, 50, 40) ;создаем кнопку подключения
GUISetState() ; Show GUI
$iHostName = GUICtrlCreateInput("HOST", 60, 90, 180, 21, $ES_CENTER)
$Checkbox1 = _Metro_CreateCheckbox("", 295, 40, 25, 25)
GUISetState() ; Show GUI)
;Set resizing options for the controls so they don't change in size or position. This can be customized to match your gui perfectly for resizing. See AutoIt Help file.

GUICtrlSetResizing($Button1, $GUI_DOCKSIZE+$GUI_DOCKHCENTER+$GUI_DOCKVCENTER)
GUICtrlSetResizing($Button2, $GUI_DOCKSIZE+$GUI_DOCKHCENTER+$GUI_DOCKVCENTER)
GUICtrlSetResizing($Checkbox1, $GUI_DOCKSIZE+$GUI_DOCKHCENTER+$GUI_DOCKVCENTER)

GUISetState(@SW_SHOW)


GUISetOnEvent($GUI_EVENT_CLOSE, "_GUIEvent_ControlButtons")
GUICtrlSetOnEvent($GUI_CLOSE_BUTTON, "_GUIEvent_ControlButtons")
GUICtrlSetOnEvent($GUI_MAXIMIZE_BUTTON, "_GUIEvent_ControlButtons")
GUICtrlSetOnEvent($GUI_MINIMIZE_BUTTON, "_GUIEvent_ControlButtons")
GUICtrlSetOnEvent($GUI_RESTORE_BUTTON, "_GUIEvent_ControlButtons")
GUICtrlSetOnEvent($GUI_MENU_BUTTON, "_GUIEvent_ControlButtons")
GUICtrlSetOnEvent($Button1, "_GUIEvent_Buttons")
GUICtrlSetOnEvent($Checkbox1, "_GUIEvent_Checkboxes")

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

    EndSwitch
 EndFunc   ;==>_GUIEvent_Checkboxes



GUISetOnEvent($GUI_EVENT_CLOSE,"Exit1") ; If you press the X button ---> Call Function Exit1
GUICtrlSetOnEvent($Button1,"Pings") ; If Click to Button ---> Call Function Note
GUISetState()

Func  Pings()
   Run("C:\Program Files (x86)\DiJo\Ping\Ping.exe")
EndFunc


While 2
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2
            $rHostName = GUICtrlRead($iHostName)
            If $rHostName <> '' Then
                If _Metro_CheckboxUnCheck($Checkbox1) Then ;отмечен чекбокс
                    RunWait(@ComSpec & ' /c C:\Windows\System32\Ping.exe ' & $rHostName & '')
                 EndIf
              EndIf

         EndSwitch
WEnd



While 3
    Sleep(5)
WEnd

 

Edited by DirtyJohny
This simple example)
  • 2 weeks later...
  • 2 weeks later...
Posted (edited)

@DirtyJohny , у меня работают флажки, но ни кнопки, ни флажки не инициируют выполнения какого-либо действия. В этом проблема? Чего конкретно ты пытаешься добиться?

Edit:

 

checkboxes work for me, but neither buttons nor checkboxes initiate any action. Is that the problem? What exactly are you trying to achieve?

Edited by JLogan3o13
Posted

I don't mind to use English, but seems like this guy won't understand me, so I tried to make it little easier for him. Perhaps, he has already found an answer in russian forum, though🙂

Posted (edited)
19 hours ago, pat4005 said:

I don't mind to use English, but seems like this guy won't understand me, so I tried to make it little easier for him. Perhaps, he has already found an answer in russian forum, though🙂

Don't worry.I fing issue, but using standart checkboxes,thanks)I haven't see that google translator set on.😅🤣Sorry😊

Edited by DirtyJohny
  • 1 month later...
Posted (edited)

If anyone experiencing problems with creating CheckboxEx2 (script crashes with exit code 3221225477) I've found a solution. At the end of a function _Metro_CreateCheckboxEx2 was used wrong fuction to dispose a graphic object: instead of a using _GDIPlus_PenDispose for a pen there is a _GDIPlus_BrushDispose function.

This is how it is now:

_GDIPlus_BrushDispose($Pen1)
_GDIPlus_BrushDispose($Pen2)

and this is how it has to be:

_GDIPlus_PenDispose($Pen1)
_GDIPlus_PenDispose($Pen2)

Interesting that I have observed it only when running non-compiled script.

Edited by pat4005
Posted
On 1/7/2021 at 10:38 AM, aaronhunter said:

Hi all

Does anyone use the command "Dircopy" in the this UDF?

It seems like doesn't work.

What do you mean "doesn't work". Function DirCopy in your script? UDF itself when using DirCopy? Can you be more specific, please?

Posted
8 hours ago, pat4005 said:

What do you mean "doesn't work". Function DirCopy in your script? UDF itself when using DirCopy? Can you be more specific, please?

My script base on this UDF. But the command "DirCopy" dosen't work on the script. I mean it doesn't do anything , show any error message.

So I'm curious about does anyone use the command "DirCopy" with this UDF?

Posted (edited)
2 hours ago, FrancescoDiMuro said:

@aaronhunter
You should always post the code, so we can see what's going on in your script :)

@FrancescoDiMuro Here is the script. The script run ok until the command "DirCopy" (even the DirCreate run fine).

If I don't use this UDF, "DirCopy" work fine. So I don't know what's wrong .😂

; ===============================================================================================================================
; Name ..........: MetroGUI UDF Example
; Version .......: v5.1
; Author ........: BB_19
; ===============================================================================================================================
Opt("GUIOnEventMode", 1)
;!Highly recommended for improved overall performance and responsiveness of the GUI effects etc.! (after compiling):
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so /rm /pe

;YOU NEED TO EXCLUDE FOLLOWING FUNCTIONS FROM AU3STRIPPER, OTHERWISE IT WON'T WORK:
#Au3Stripper_Ignore_Funcs=_iHoverOn,_iHoverOff,_iMinBtn,_iMaxBtn,_iCloseBtn,_iRestoreBtn,_iFullscreenToggleBtn,_cHvr_CSCP_X64,_cHvr_CSCP_X86,_iControlDelete
;Please not that Au3Stripper will show errors. You can ignore them as long as you use the above Au3Stripper_Ignore_Funcs parameters.

;Required if you want High DPI scaling enabled. (Also requries _Metro_EnableHighDPIScaling())
#AutoIt3Wrapper_Res_HiDpi=y
; ===============================================================================================================================

#NoTrayIcon
#include "MetroGUI-UDF\MetroGUI_UDF.au3"
#include "MetroGUI-UDF\_GUIDisable.au3" ; For dim effects when msgbox is displayed
#include <GUIConstants.au3>
#include <ScreenCapture.au3>
#include <ComboConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>
#include <ScreenCapture.au3>
#include <Array.au3>
#include <File.au3>
#include <Excel.au3>
#Include <Misc.au3>
#include <AutoItConstants.au3>

;=======================================================================Creating the GUI===============================================================================
;Enable high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp.
_Metro_EnableHighDPIScaling() ; Note: Requries "#AutoIt3Wrapper_Res_HiDpi=y" for compiling. To see visible changes without compiling, you have to disable dpi scaling in compatibility settings of Autoit3.exe
;~ $OnEventMode = True

;Set Theme
_SetTheme("DarkBlue") ;See MetroThemes.au3 for selectable themes or to add more

;Create resizable Metro GUI
$Form1 = _Metro_CreateGUI("", 140, 100, -1, -1, False) ;設140白線會不見

;Add/create control buttons to the GUI
$Control_Buttons = _Metro_AddControlButtons(True, False, False, False, False) ;CloseBtn = True, MaximizeBtn = True, MinimizeBtn = True, FullscreenBtn = True, MenuBtn = True

;Create  Buttons
$Button1 = _Metro_CreateButtonEx2("還原驅動", 10, 40, 115, 40)
;~ $Button2 = _Metro_CreateButtonEx2("還原驅動", 10, 85, 115, 40)


GUISetState(@SW_SHOW)

;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.)
;All control buttons like maximize, minimize, fullscreen etc. (except the menu button) work natively. You can use these variables to handle the clicks manually, if you do so, then make sure set $ControlBtnsAutoMode = False
$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]


;~ MsgBox(0, "", $DriverFilePath1,0)
;~ MsgBox(0, "", $DriverFilePath2,0)
;~ MsgBox(0, "", $DriverFilePath3,0)

GUISetState(@SW_SHOW)

GUICtrlSetOnEvent($GUI_CLOSE_BUTTON, "_GUIEvent_ControlButtons")
GUICtrlSetOnEvent($Button1, "_GUIEvent_Buttons")
;~ GUICtrlSetOnEvent($Button2, "_GUIEvent_Buttons")


While 1
    Sleep(5)
WEnd

Func _GUIEvent_ControlButtons()
    Switch @GUI_CtrlId
        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
    EndSwitch
EndFunc   ;==>_GUIEvent_ControlButtons


Func _GUIEvent_Buttons()
    Switch @GUI_CtrlId
    Case $Button1
       DirCreate("D:\temp\")
       DirCopy("C:\temp\", "D:\temp\")
       EndSwitch
EndFunc   ;==>_GUIEvent_Buttons

 

Edited by aaronhunter
added codebox
Posted

Hi aaronhunter :)
If you want DirCopy to work in your script, then you need to use the 3rd parameter of the function.

DirCreate("D:\temp\")
DirCopy("C:\temp\", "D:\temp\", $FC_OVERWRITE)

As you don't use this 3rd parameter, then the function fails because the destination directory already exists.
A good way to know if the function succeeded is to test its result (which has nothing to do with @error) :

#include <FileConstants.au3>

$iStatus = DirCopy("C:\temp\", "D:\temp\", $FC_OVERWRITE)
If $iStatus = 0 Then ; 0 = failure, 1 = success
    ; your error message here
EndIf

 

Posted (edited)
On 1/16/2021 at 2:05 AM, pixelsearch said:

Hi aaronhunter :)
If you want DirCopy to work in your script, then you need to use the 3rd parameter of the function.

DirCreate("D:\temp\")
DirCopy("C:\temp\", "D:\temp\", $FC_OVERWRITE)

As you don't use this 3rd parameter, then the function fails because the destination directory already exists.
A good way to know if the function succeeded is to test its result (which has nothing to do with @error) :

#include <FileConstants.au3>

$iStatus = DirCopy("C:\temp\", "D:\temp\", $FC_OVERWRITE)
If $iStatus = 0 Then ; 0 = failure, 1 = success
    ; your error message here
EndIf

 

wow it's working. Thank you so much.

But I can't figure out why the directory even don't exist in the destination, the function still doesn't work.

And even in a new script , just 2 line of code like what you write

#include <FileConstants.au3>
$iStatus = DirCopy("C:\temp\", "D:\temp\")

Even don't need the 3rd parameter , it  works fine.(that's why I didn't use the 3rd parameter in my script that based on the UDF, I thought it's not necessary.)

Anyway thank you for fix my issue , let me learn something from here.🙇‍♂️

Edited by aaronhunter
  • 3 months later...

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
×
×
  • Create New...