Detre
Новичок
- Сообщения
- 70
- Репутация
- 0
Всем доброго дня, есть ли знающие люди в кастоме MetroGUI UDF? Знаю, что лучше юзать штатные решения предусмотренные в autoit, но оболочка пришлась по вкусу.Вопрос следующий, не работает _Metro_CreateCheckbox в паре с GUICtrlCreateInput.То есть мне нужно поставить галку для выбора той или иной функции чтобы взаимодействовать с input, в прошлом коде все работает, в прошлом писал по поводу checkbox(прям болезнь для меня),знающие люди помогли и огромный им респект.
Прилагаю работающий код.
А вот товарищ, которого надо научить работать.
Прилагаю работающий код.
Код:
#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
А вот товарищ, которого надо научить работать.
Код:
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