Что нового

Элементы GUI Не работают кнопки в GUI

Пост номер 6 был отмечен как лучший ответ.

DirtyJohny

Новичок
Сообщения
35
Репутация
0
Нужна помощь с GUI.Взял готовый GUI (да-да нагло спер с Se7enstars) и хотел впихнуть со своей прошлой поделки и тут не работают кнопки, очень рассчитываю на вашу помощь)
Код:
#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 <WinAPISysWin.au3>
#RequireAdmin
#NoTrayIcon

Opt("GUIOnEventMode", 1)

Global $Assets = @ScriptDir & "\Assets\"

Global $cUI_BK = 0x02101B
Global $cContent_BK = 0x091926
Global $cText = 0xDEDEDE
Global $cTextA = 0x56CBDD
Global $cCardBk = 0x0C1C29

Global $lastMenu = Default
Global $isOnTop = False
Global $ui_w = 800
Global $ui_h = 520
Global $topPanel_h = CalcPercent(12, $ui_h)
Global $bottomPanel_h = CalcPercent(8, $ui_h)
Global $bottomPanel_y = $ui_h - $bottomPanel_h
Global $leftPanel_w = CalcPercent(25, $ui_w)
Global $contentPanel_x = $leftPanel_w
Global $contentPanel_y = $topPanel_h
Global $contentPanel_w = $ui_w - $leftPanel_w
Global $contentPanel_h = $ui_h - ($topPanel_h + $bottomPanel_h)


Global $UI = GUICreate("Experience UI", $ui_w, $ui_h) ; $WS_POPUP, $WS_EX_CONTROLPARENT
WinSetTrans($UI, "", 0);
GUISetState(@SW_SHOW, $UI)
For $i = 0 To 243 Step 2
    WinSetTrans($UI, "", $i);Прозрачность 0-255

Next

GUISetOnEvent(-3, "Terminate", $UI)
GUISetBkColor($cUI_BK, $UI)

Global $topPanel = GUICtrlCreateLabel("", 0, 0, $ui_w, $topPanel_h) ; height = 12% from UI | (ps. $GUI_WS_EX_PARENTDRAG)
GUICtrlSetState($topPanel, 128) ; $GUI_DISABLE
GUICtrlSetBkColor($topPanel, $cUI_BK)

Global $bottomPanel = GUICtrlCreateLabel("", 0, $bottomPanel_y, $ui_w, $bottomPanel_h)
GUICtrlSetState($bottomPanel, 128) ; $GUI_DISABLE
GUICtrlSetBkColor($bottomPanel, $cUI_BK)

Global $leftPanel = GUICtrlCreateLabel("", 0, $topPanel_h, $leftPanel_w, $ui_h - ($topPanel_h + $bottomPanel_h))
GUICtrlSetState($leftPanel, 128) ; $GUI_DISABLE
GUICtrlSetBkColor($leftPanel, $cUI_BK)

Global $contentPanel = GUICtrlCreateLabel("", $contentPanel_x, $contentPanel_y, $contentPanel_w, $contentPanel_h)
GUICtrlSetState($contentPanel, 128) ; $GUI_DISABLE
GUICtrlSetBkColor($contentPanel, $cContent_BK)

$y = $bottomPanel_y + (($bottomPanel_h / 2) - (28 / 2))
GUICtrlCreateLabel("© 2020 by DiJo.", 10, $y, $leftPanel_w - 38, 28, 0x0200)
GUICtrlSetFont(-1, 8, Default, Default, "Segoe UI", 5) ; 5 = Clear Type
GUICtrlSetColor(-1, $cText)

Global $y = $topPanel_h
GUICtrlCreateLabel(" FNKC Pack", 52, $y, $leftPanel_w - 52, 32, 0x0200)
GUICtrlSetFont(-1, 12, 600, Default, "Segoe UI", 5) ; 5 = Clear Type
GUICtrlSetColor(-1, $cText)

$y += 50
Global $vDashboard = GUICtrlCreateLabel("Mode 1", 38, $y, $leftPanel_w - 38, 32, 0x0200)
GUICtrlSetOnEvent(-1, "DashboardEvent")
GUICtrlSetFont(-1, 11, 600, Default, "Segoe UI", 5) ; 5 = Clear Type
GUICtrlSetColor(-1, $cTextA)
GUICtrlSetCursor(-1, 0)
$lastMenu = $vDashboard
$y += 32
Global $vWallet = GUICtrlCreateLabel("Mode 2", 38, $y, $leftPanel_w - 38, 32, 0x0200)
GUICtrlSetOnEvent(-1, "WalletEvent")
GUICtrlSetFont(-1, 11, 600, Default, "Segoe UI", 5) ; 5 = Clear Type
GUICtrlSetColor(-1, $cText)
GUICtrlSetCursor(-1, 0)
$y += 32
Global $vMessages = GUICtrlCreateLabel("Mode 3", 38, $y, $leftPanel_w - 38, 32, 0x0200)
GUICtrlSetOnEvent(-1, "MessagesEvent")
GUICtrlSetFont(-1, 11, 600, Default, "Segoe UI", 5) ; 5 = Clear Type
GUICtrlSetColor(-1, $cText)
GUICtrlSetCursor(-1, 0)

$y = ($topPanel_h + 50)
Global $vIndicator = GUICtrlCreateLabel("", 0, $y, 4, 32)
GUICtrlSetBkColor(-1, $cTextA)


$x = $contentPanel_x + 10
$y = $contentPanel_y + 15
Global $iHostName = GUICtrlCreateInput("", $x+ 200, $y + 10, 180, 21)
Global $Button1 = GUICtrlCreateButton("Ping", $x, $y + 80, 267, 43)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") ;задаем стиль элементу выше
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x0E0C2E)
Global $Button2 = GUICtrlCreateButton("ChangePass", $x + 310, $y + 80, 267, 43)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") ;задаем стиль элементу выше
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x0E0C2E)
GUISetState() ; Show GUI
Global $Button3 = GUICtrlCreateButton("Start", $x, $y + 140, 267, 43) ;создаем кнопку подключения
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") ;задаем стиль элементу выше
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x0E0C2E)
GUISetState() ; Show GUI

Global $Checkbox1 = GUICtrlCreateCheckbox("", $x+ 273, $y + 95, 12, 12)
Global $Checkbox2 = GUICtrlCreateCheckbox("", $x+ 293, $y + 95, 12, 12)

GUISetState() ; Show GUI
Local $rHostName
While True
    Sleep(10)
WEnd

Func DashboardEvent()
    If $lastMenu <> $vDashboard Then
        Local $CGP = ControlGetPos($UI, '', $vDashboard)
        GUICtrlSetPos($vIndicator, 0, $CGP[1])
        GUICtrlSetColor($vDashboard, $cTextA)
        GUICtrlSetColor($lastMenu, $cText)
        $lastMenu = $vDashboard
        GUICtrlSetState($Button1, $GUI_SHOW)
        GUICtrlSetState($Button2, $GUI_SHOW)

        GUICtrlSetState($Checkbox1, $GUI_SHOW)
        GUICtrlSetState($Checkbox2, $GUI_SHOW)

        ConsoleWrite(1)
    EndIf
EndFunc   ;==>DashboardEvent

Func WalletEvent()
    If $lastMenu <> $vWallet Then
        Local $CGP = ControlGetPos($UI, '', $vWallet)
        GUICtrlSetPos($vIndicator, 0, $CGP[1])
        GUICtrlSetColor($vWallet, $cTextA)
        GUICtrlSetColor($lastMenu, $cText)
        $lastMenu = $vWallet
        GUICtrlSetState($Button1, $GUI_HIDE)
        GUICtrlSetState($Button2, $GUI_HIDE)

        GUICtrlSetState($Checkbox1, $GUI_HIDE)
        GUICtrlSetState($Checkbox2, $GUI_HIDE)

        ConsoleWrite(1)
    EndIf
EndFunc   ;==>WalletEvent

Func MessagesEvent()
    If $lastMenu <> $vMessages Then
        Local $CGP = ControlGetPos($UI, '', $vMessages)
        GUICtrlSetPos($vIndicator, 0, $CGP[1])
        GUICtrlSetColor($vMessages, $cTextA)
        GUICtrlSetColor($lastMenu, $cText)
        $lastMenu = $vMessages
        GUICtrlSetState($Button1, $GUI_HIDE)
        GUICtrlSetState($Button2, $GUI_HIDE)

        GUICtrlSetState($Checkbox1, $GUI_HIDE)
        GUICtrlSetState($Checkbox2, $GUI_HIDE)

        ConsoleWrite(1)
    EndIf
EndFunc   ;==>MessagesEvent


While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button3
            $rHostName = GUICtrlRead($iHostName)
            If $rHostName <> '' Then
                If GUICtrlRead($Checkbox1) = 1 Then ;отмечен чекбокс
                    Run(@ComSpec & ' /c C:\Windows\System32\Ping.exe ' & $rHostName & ' -t')
                 EndIf
                If GUICtrlRead($Checkbox2) = 1 Then ;отмечен чекбокс
                    RunWait(@ComSpec & ' /c PsPasswd \\' & $rHostName & ' Администратор Mik35')
                 EndIf
              EndIf

       Case $Button1
                $rHostName = GUICtrlRead($iHostName)
                   Run(@ComSpec & ' /c C:\Windows\System32\Ping.exe ' & $rHostName & ' -t')
       Case $Button2
                $rHostName = GUICtrlRead($iHostName)
                   RunWait(@ComSpec & ' /c PsPasswd \\' & $rHostName & ' Администратор Mik35')

         EndSwitch
WEnd


Func Terminate()
    GUIDelete($UI)
    Exit
EndFunc   ;==>Terminate

Func Minimize()
    GUISetState(@SW_MINIMIZE, $UI)
EndFunc   ;==>Minimize


Func Topmost()
    If $isOnTop = False Then
        WinSetOnTop($UI, Default, 1)
        $isOnTop = True
    Else
        WinSetOnTop($UI, Default, 0)
        $isOnTop = False
    EndIf
EndFunc   ;==>Topmost

Func CalcPercent($vPercent, $vInt) ; Calculate percent % :)
    Return $vPercent * $vInt / 100
EndFunc   ;==>CalcPercent
 
Последнее редактирование:

joiner

Модератор
Локальный модератор
Сообщения
3 362
Репутация
586
GuiGetMsg() не совместим с режимом GUIOnEventMode. То есть, в данном коде работает только GUIOnEventMode. Значит, на чекбосы нужно назначать функции этим же способом. Либо отключить GUIOnEventMode и работать только через GuiGetMsg
 
Автор
DirtyJohny

DirtyJohny

Новичок
Сообщения
35
Репутация
0
GuiGetMsg() не совместим с режимом GUIOnEventMode. То есть, в данном коде работает только GUIOnEventMode. Значит, на чекбосы нужно назначать функции этим же способом. Либо отключить GUIOnEventMode и работать только через GuiGetMsg
Я совсем новичок, словно картошка. Не поможете?) Туплю, что на что поменять?) Что тогда будет работать вместо GuiGetMsg?
 
Последнее редактирование:

joiner

Модератор
Локальный модератор
Сообщения
3 362
Репутация
586
В данном коде второй цикл
While 1....Wend лишний
Его удалить, а действия из него оформить в виде функций и прописать под чекбоксами как это сделано у других элементов.
 
Автор
DirtyJohny

DirtyJohny

Новичок
Сообщения
35
Репутация
0
В данном коде второй цикл
While 1....Wend лишний
Его удалить, а действия из него оформить в виде функций и прописать под чекбоксами как это сделано у других элементов.
Я сменил While на func,пока удалил команды на чекбоксы. Плюс добавил GUICtrlSetOnEvent(-1, '_Didshit') Но все равно не работат(
Код:
#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 <WinAPISysWin.au3>
#RequireAdmin
#NoTrayIcon

Opt("GUIOnEventMode", 1)

Global $Assets = @ScriptDir & "\Assets\"

Global $cUI_BK = 0x02101B
Global $cContent_BK = 0x091926
Global $cText = 0xDEDEDE
Global $cTextA = 0x56CBDD
Global $cCardBk = 0x0C1C29

Global $lastMenu = Default
Global $isOnTop = False
Global $ui_w = 800
Global $ui_h = 520
Global $topPanel_h = CalcPercent(12, $ui_h)
Global $bottomPanel_h = CalcPercent(8, $ui_h)
Global $bottomPanel_y = $ui_h - $bottomPanel_h
Global $leftPanel_w = CalcPercent(25, $ui_w)
Global $contentPanel_x = $leftPanel_w
Global $contentPanel_y = $topPanel_h
Global $contentPanel_w = $ui_w - $leftPanel_w
Global $contentPanel_h = $ui_h - ($topPanel_h + $bottomPanel_h)


Global $UI = GUICreate("Experience UI", $ui_w, $ui_h) ; $WS_POPUP, $WS_EX_CONTROLPARENT
WinSetTrans($UI, "", 0);
GUISetState(@SW_SHOW, $UI)
For $i = 0 To 243 Step 2
    WinSetTrans($UI, "", $i);Прозрачность 0-255

Next

GUISetOnEvent(-3, "Terminate", $UI)
GUISetBkColor($cUI_BK, $UI)

Global $topPanel = GUICtrlCreateLabel("", 0, 0, $ui_w, $topPanel_h) ; height = 12% from UI | (ps. $GUI_WS_EX_PARENTDRAG)
GUICtrlSetState($topPanel, 128) ; $GUI_DISABLE
GUICtrlSetBkColor($topPanel, $cUI_BK)

Global $bottomPanel = GUICtrlCreateLabel("", 0, $bottomPanel_y, $ui_w, $bottomPanel_h)
GUICtrlSetState($bottomPanel, 128) ; $GUI_DISABLE
GUICtrlSetBkColor($bottomPanel, $cUI_BK)

Global $leftPanel = GUICtrlCreateLabel("", 0, $topPanel_h, $leftPanel_w, $ui_h - ($topPanel_h + $bottomPanel_h))
GUICtrlSetState($leftPanel, 128) ; $GUI_DISABLE
GUICtrlSetBkColor($leftPanel, $cUI_BK)

Global $contentPanel = GUICtrlCreateLabel("", $contentPanel_x, $contentPanel_y, $contentPanel_w, $contentPanel_h)
GUICtrlSetState($contentPanel, 128) ; $GUI_DISABLE
GUICtrlSetBkColor($contentPanel, $cContent_BK)

$y = $bottomPanel_y + (($bottomPanel_h / 2) - (28 / 2))
GUICtrlCreateLabel("© 2020 by DiJo.", 10, $y, $leftPanel_w - 38, 28, 0x0200)
GUICtrlSetFont(-1, 8, Default, Default, "Segoe UI", 5) ; 5 = Clear Type
GUICtrlSetColor(-1, $cText)

Global $y = $topPanel_h
GUICtrlCreateLabel(" FNKC Pack", 52, $y, $leftPanel_w - 52, 32, 0x0200)
GUICtrlSetFont(-1, 12, 600, Default, "Segoe UI", 5) ; 5 = Clear Type
GUICtrlSetColor(-1, $cText)

$y += 50
Global $vDashboard = GUICtrlCreateLabel("Mode 1", 38, $y, $leftPanel_w - 38, 32, 0x0200)
GUICtrlSetOnEvent(-1, "DashboardEvent")
GUICtrlSetFont(-1, 11, 600, Default, "Segoe UI", 5) ; 5 = Clear Type
GUICtrlSetColor(-1, $cTextA)
GUICtrlSetCursor(-1, 0)
$lastMenu = $vDashboard
$y += 32
Global $vWallet = GUICtrlCreateLabel("Mode 2", 38, $y, $leftPanel_w - 38, 32, 0x0200)
GUICtrlSetOnEvent(-1, "WalletEvent")
GUICtrlSetFont(-1, 11, 600, Default, "Segoe UI", 5) ; 5 = Clear Type
GUICtrlSetColor(-1, $cText)
GUICtrlSetCursor(-1, 0)
$y += 32
Global $vMessages = GUICtrlCreateLabel("Mode 3", 38, $y, $leftPanel_w - 38, 32, 0x0200)
GUICtrlSetOnEvent(-1, "MessagesEvent")
GUICtrlSetFont(-1, 11, 600, Default, "Segoe UI", 5) ; 5 = Clear Type
GUICtrlSetColor(-1, $cText)
GUICtrlSetCursor(-1, 0)

$y = ($topPanel_h + 50)
Global $vIndicator = GUICtrlCreateLabel("", 0, $y, 4, 32)
GUICtrlSetBkColor(-1, $cTextA)


$x = $contentPanel_x + 10
$y = $contentPanel_y + 15
Global $iHostName = GUICtrlCreateInput("", $x+ 200, $y + 10, 180, 21)
Global $Button1 = GUICtrlCreateButton("Ping", $x, $y + 80, 267, 43)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") ;задаем стиль элементу выше
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x0E0C2E)
Global $Button2 = GUICtrlCreateButton("ChangePass", $x + 310, $y + 80, 267, 43)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") ;задаем стиль элементу выше
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x0E0C2E)
GUISetState() ; Show GUI
Global $Button3 = GUICtrlCreateButton("Start", $x, $y + 140, 267, 43) ;создаем кнопку подключения
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") ;задаем стиль элементу выше
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x0E0C2E)
GUISetState() ; Show GUI

Global $Checkbox1 = GUICtrlCreateCheckbox("", $x+ 273, $y + 95, 12, 12)
Global $Checkbox2 = GUICtrlCreateCheckbox("", $x+ 293, $y + 95, 12, 12)

GUICtrlSetOnEvent(-1, '_Didshit')
GUISetState() ; Show GUI
Local $rHostName
While True
    Sleep(10)
WEnd

Func DashboardEvent()
    If $lastMenu <> $vDashboard Then
        Local $CGP = ControlGetPos($UI, '', $vDashboard)
        GUICtrlSetPos($vIndicator, 0, $CGP[1])
        GUICtrlSetColor($vDashboard, $cTextA)
        GUICtrlSetColor($lastMenu, $cText)
        $lastMenu = $vDashboard
        GUICtrlSetState($Button1, $GUI_SHOW)
        GUICtrlSetState($Button2, $GUI_SHOW)

        GUICtrlSetState($Checkbox1, $GUI_SHOW)
        GUICtrlSetState($Checkbox2, $GUI_SHOW)

        ConsoleWrite(1)
    EndIf
EndFunc   ;==>DashboardEvent

Func WalletEvent()
    If $lastMenu <> $vWallet Then
        Local $CGP = ControlGetPos($UI, '', $vWallet)
        GUICtrlSetPos($vIndicator, 0, $CGP[1])
        GUICtrlSetColor($vWallet, $cTextA)
        GUICtrlSetColor($lastMenu, $cText)
        $lastMenu = $vWallet
        GUICtrlSetState($Button1, $GUI_HIDE)
        GUICtrlSetState($Button2, $GUI_HIDE)

        GUICtrlSetState($Checkbox1, $GUI_HIDE)
        GUICtrlSetState($Checkbox2, $GUI_HIDE)

        ConsoleWrite(1)
    EndIf
EndFunc   ;==>WalletEvent

Func MessagesEvent()
    If $lastMenu <> $vMessages Then
        Local $CGP = ControlGetPos($UI, '', $vMessages)
        GUICtrlSetPos($vIndicator, 0, $CGP[1])
        GUICtrlSetColor($vMessages, $cTextA)
        GUICtrlSetColor($lastMenu, $cText)
        $lastMenu = $vMessages
        GUICtrlSetState($Button1, $GUI_HIDE)
        GUICtrlSetState($Button2, $GUI_HIDE)

        GUICtrlSetState($Checkbox1, $GUI_HIDE)
        GUICtrlSetState($Checkbox2, $GUI_HIDE)

        ConsoleWrite(1)
    EndIf
EndFunc   ;==>MessagesEvent

GUICtrlSetOnEvent(-1, '_Didshit')

Func _Didshit()
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
         Case $Button1
                $rHostName = GUICtrlRead($iHostName)
                   Run(@ComSpec & ' /c C:\Windows\System32\Ping.exe ' & $rHostName & ' -t')
       Case $Button2
                $rHostName = GUICtrlRead($iHostName)
                   RunWait(@ComSpec & ' /c PsPasswd \\' & $rHostName & ' Администратор Mik35')

         EndSwitch
EndFunc


Func Terminate()
    GUIDelete($UI)
    Exit
EndFunc   ;==>Terminate

Func Minimize()
    GUISetState(@SW_MINIMIZE, $UI)
EndFunc   ;==>Minimize


Func Topmost()
    If $isOnTop = False Then
        WinSetOnTop($UI, Default, 1)
        $isOnTop = True
    Else
        WinSetOnTop($UI, Default, 0)
        $isOnTop = False
    EndIf
EndFunc   ;==>Topmost

Func CalcPercent($vPercent, $vInt) ; Calculate percent % :)
    Return $vPercent * $vInt / 100
EndFunc   ;==>CalcPercent
 

joiner

Модератор
Локальный модератор
Сообщения
3 362
Репутация
586
Код:
#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 <WinAPISysWin.au3>
#RequireAdmin
#NoTrayIcon

Opt("GUIOnEventMode", 1)

Global $Assets = @ScriptDir & "\Assets\"

Global $cUI_BK = 0x02101B
Global $cContent_BK = 0x091926
Global $cText = 0xDEDEDE
Global $cTextA = 0x56CBDD
Global $cCardBk = 0x0C1C29

Global $lastMenu = Default
Global $isOnTop = False
Global $ui_w = 800
Global $ui_h = 520
Global $topPanel_h = CalcPercent(12, $ui_h)
Global $bottomPanel_h = CalcPercent(8, $ui_h)
Global $bottomPanel_y = $ui_h - $bottomPanel_h
Global $leftPanel_w = CalcPercent(25, $ui_w)
Global $contentPanel_x = $leftPanel_w
Global $contentPanel_y = $topPanel_h
Global $contentPanel_w = $ui_w - $leftPanel_w
Global $contentPanel_h = $ui_h - ($topPanel_h + $bottomPanel_h)


Global $UI = GUICreate("Experience UI", $ui_w, $ui_h) ; $WS_POPUP, $WS_EX_CONTROLPARENT
WinSetTrans($UI, "", 0);
GUISetState(@SW_SHOW, $UI)
For $i = 0 To 243 Step 2
    WinSetTrans($UI, "", $i);Прозрачность 0-255

Next

GUISetOnEvent(-3, "Terminate", $UI)
GUISetBkColor($cUI_BK, $UI)

Global $topPanel = GUICtrlCreateLabel("", 0, 0, $ui_w, $topPanel_h) ; height = 12% from UI | (ps. $GUI_WS_EX_PARENTDRAG)
GUICtrlSetState($topPanel, 128) ; $GUI_DISABLE
GUICtrlSetBkColor($topPanel, $cUI_BK)

Global $bottomPanel = GUICtrlCreateLabel("", 0, $bottomPanel_y, $ui_w, $bottomPanel_h)
GUICtrlSetState($bottomPanel, 128) ; $GUI_DISABLE
GUICtrlSetBkColor($bottomPanel, $cUI_BK)

Global $leftPanel = GUICtrlCreateLabel("", 0, $topPanel_h, $leftPanel_w, $ui_h - ($topPanel_h + $bottomPanel_h))
GUICtrlSetState($leftPanel, 128) ; $GUI_DISABLE
GUICtrlSetBkColor($leftPanel, $cUI_BK)

Global $contentPanel = GUICtrlCreateLabel("", $contentPanel_x, $contentPanel_y, $contentPanel_w, $contentPanel_h)
GUICtrlSetState($contentPanel, 128) ; $GUI_DISABLE
GUICtrlSetBkColor($contentPanel, $cContent_BK)

$y = $bottomPanel_y + (($bottomPanel_h / 2) - (28 / 2))
GUICtrlCreateLabel("© 2020 by DiJo.", 10, $y, $leftPanel_w - 38, 28, 0x0200)
GUICtrlSetFont(-1, 8, Default, Default, "Segoe UI", 5) ; 5 = Clear Type
GUICtrlSetColor(-1, $cText)

Global $y = $topPanel_h
GUICtrlCreateLabel(" FNKC Pack", 52, $y, $leftPanel_w - 52, 32, 0x0200)
GUICtrlSetFont(-1, 12, 600, Default, "Segoe UI", 5) ; 5 = Clear Type
GUICtrlSetColor(-1, $cText)

$y += 50
Global $vDashboard = GUICtrlCreateLabel("Mode 1", 38, $y, $leftPanel_w - 38, 32, 0x0200)
GUICtrlSetOnEvent(-1, "DashboardEvent")
GUICtrlSetFont(-1, 11, 600, Default, "Segoe UI", 5) ; 5 = Clear Type
GUICtrlSetColor(-1, $cTextA)
GUICtrlSetCursor(-1, 0)
$lastMenu = $vDashboard
$y += 32
Global $vWallet = GUICtrlCreateLabel("Mode 2", 38, $y, $leftPanel_w - 38, 32, 0x0200)
GUICtrlSetOnEvent(-1, "WalletEvent")
GUICtrlSetFont(-1, 11, 600, Default, "Segoe UI", 5) ; 5 = Clear Type
GUICtrlSetColor(-1, $cText)
GUICtrlSetCursor(-1, 0)
$y += 32
Global $vMessages = GUICtrlCreateLabel("Mode 3", 38, $y, $leftPanel_w - 38, 32, 0x0200)
GUICtrlSetOnEvent(-1, "MessagesEvent")
GUICtrlSetFont(-1, 11, 600, Default, "Segoe UI", 5) ; 5 = Clear Type
GUICtrlSetColor(-1, $cText)
GUICtrlSetCursor(-1, 0)

$y = ($topPanel_h + 50)
Global $vIndicator = GUICtrlCreateLabel("", 0, $y, 4, 32)
GUICtrlSetBkColor(-1, $cTextA)

$x = $contentPanel_x + 10
$y = $contentPanel_y + 15
Global $iHostName = GUICtrlCreateInput("", $x + 200, $y + 10, 180, 21)
Global $Button1 = GUICtrlCreateButton("Ping", $x, $y + 80, 267, 43)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") ;задаем стиль элементу выше
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x0E0C2E)
GUICtrlSetOnEvent(-1, "_Didshit1")
Global $Button2 = GUICtrlCreateButton("ChangePass", $x + 310, $y + 80, 267, 43)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") ;задаем стиль элементу выше
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x0E0C2E)
GUICtrlSetOnEvent(-1, "_Didshit2")
Global $Button3 = GUICtrlCreateButton("Start", $x, $y + 140, 267, 43) ;создаем кнопку подключения
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") ;задаем стиль элементу выше
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x0E0C2E)

Global $Checkbox1 = GUICtrlCreateCheckbox("", $x + 273, $y + 95, 12, 12)
Global $Checkbox2 = GUICtrlCreateCheckbox("", $x + 293, $y + 95, 12, 12)

GUISetState() ; Show GUI
Global $rHostName
While True
    Sleep(10)
WEnd

Func DashboardEvent()
    If $lastMenu <> $vDashboard Then
        Local $CGP = ControlGetPos($UI, '', $vDashboard)
        GUICtrlSetPos($vIndicator, 0, $CGP[1])
        GUICtrlSetColor($vDashboard, $cTextA)
        GUICtrlSetColor($lastMenu, $cText)
        $lastMenu = $vDashboard
        GUICtrlSetState($Button1, $GUI_SHOW)
        GUICtrlSetState($Button2, $GUI_SHOW)
        GUICtrlSetState($Checkbox1, $GUI_SHOW)
        GUICtrlSetState($Checkbox2, $GUI_SHOW)
        ConsoleWrite(1)
    EndIf
EndFunc   ;==>DashboardEvent

Func WalletEvent()
    If $lastMenu <> $vWallet Then
        Local $CGP = ControlGetPos($UI, '', $vWallet)
        GUICtrlSetPos($vIndicator, 0, $CGP[1])
        GUICtrlSetColor($vWallet, $cTextA)
        GUICtrlSetColor($lastMenu, $cText)
        $lastMenu = $vWallet
        GUICtrlSetState($Button1, $GUI_HIDE)
        GUICtrlSetState($Button2, $GUI_HIDE)
        GUICtrlSetState($Checkbox1, $GUI_HIDE)
        GUICtrlSetState($Checkbox2, $GUI_HIDE)
        ConsoleWrite(1)
    EndIf
EndFunc   ;==>WalletEvent

Func MessagesEvent()
    If $lastMenu <> $vMessages Then
        Local $CGP = ControlGetPos($UI, '', $vMessages)
        GUICtrlSetPos($vIndicator, 0, $CGP[1])
        GUICtrlSetColor($vMessages, $cTextA)
        GUICtrlSetColor($lastMenu, $cText)
        $lastMenu = $vMessages
        GUICtrlSetState($Button1, $GUI_HIDE)
        GUICtrlSetState($Button2, $GUI_HIDE)
        GUICtrlSetState($Checkbox1, $GUI_HIDE)
        GUICtrlSetState($Checkbox2, $GUI_HIDE)
        ConsoleWrite(1)
    EndIf
EndFunc   ;==>MessagesEvent

Func _Didshit1()
    $rHostName = GUICtrlRead($iHostName)
    Run(@ComSpec & ' /c C:\Windows\System32\Ping.exe ' & $rHostName & ' -t')
EndFunc   ;==>_Didshit1

Func _Didshit2()
    $rHostName = GUICtrlRead($iHostName)
    RunWait(@ComSpec & ' /c PsPasswd \\' & $rHostName & ' Администратор Mik35')
EndFunc   ;==>_Didshit2

Func Terminate()
    GUIDelete($UI)
    Exit
EndFunc   ;==>Terminate

Func Minimize()
    GUISetState(@SW_MINIMIZE, $UI)
EndFunc   ;==>Minimize

Func Topmost()
    If $isOnTop = False Then
        WinSetOnTop($UI, Default, 1)
        $isOnTop = True
    Else
        WinSetOnTop($UI, Default, 0)
        $isOnTop = False
    EndIf
EndFunc   ;==>Topmost

Func CalcPercent($vPercent, $vInt) ; Calculate percent % :)
    Return $vPercent * $vInt / 100
EndFunc   ;==>CalcPercent
начни вникать в справку и искать по форуму.
 
Автор
DirtyJohny

DirtyJohny

Новичок
Сообщения
35
Репутация
0
Код:
#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 <WinAPISysWin.au3>
#RequireAdmin
#NoTrayIcon

Opt("GUIOnEventMode", 1)

Global $Assets = @ScriptDir & "\Assets\"

Global $cUI_BK = 0x02101B
Global $cContent_BK = 0x091926
Global $cText = 0xDEDEDE
Global $cTextA = 0x56CBDD
Global $cCardBk = 0x0C1C29

Global $lastMenu = Default
Global $isOnTop = False
Global $ui_w = 800
Global $ui_h = 520
Global $topPanel_h = CalcPercent(12, $ui_h)
Global $bottomPanel_h = CalcPercent(8, $ui_h)
Global $bottomPanel_y = $ui_h - $bottomPanel_h
Global $leftPanel_w = CalcPercent(25, $ui_w)
Global $contentPanel_x = $leftPanel_w
Global $contentPanel_y = $topPanel_h
Global $contentPanel_w = $ui_w - $leftPanel_w
Global $contentPanel_h = $ui_h - ($topPanel_h + $bottomPanel_h)


Global $UI = GUICreate("Experience UI", $ui_w, $ui_h) ; $WS_POPUP, $WS_EX_CONTROLPARENT
WinSetTrans($UI, "", 0);
GUISetState(@SW_SHOW, $UI)
For $i = 0 To 243 Step 2
    WinSetTrans($UI, "", $i);Прозрачность 0-255

Next

GUISetOnEvent(-3, "Terminate", $UI)
GUISetBkColor($cUI_BK, $UI)

Global $topPanel = GUICtrlCreateLabel("", 0, 0, $ui_w, $topPanel_h) ; height = 12% from UI | (ps. $GUI_WS_EX_PARENTDRAG)
GUICtrlSetState($topPanel, 128) ; $GUI_DISABLE
GUICtrlSetBkColor($topPanel, $cUI_BK)

Global $bottomPanel = GUICtrlCreateLabel("", 0, $bottomPanel_y, $ui_w, $bottomPanel_h)
GUICtrlSetState($bottomPanel, 128) ; $GUI_DISABLE
GUICtrlSetBkColor($bottomPanel, $cUI_BK)

Global $leftPanel = GUICtrlCreateLabel("", 0, $topPanel_h, $leftPanel_w, $ui_h - ($topPanel_h + $bottomPanel_h))
GUICtrlSetState($leftPanel, 128) ; $GUI_DISABLE
GUICtrlSetBkColor($leftPanel, $cUI_BK)

Global $contentPanel = GUICtrlCreateLabel("", $contentPanel_x, $contentPanel_y, $contentPanel_w, $contentPanel_h)
GUICtrlSetState($contentPanel, 128) ; $GUI_DISABLE
GUICtrlSetBkColor($contentPanel, $cContent_BK)

$y = $bottomPanel_y + (($bottomPanel_h / 2) - (28 / 2))
GUICtrlCreateLabel("© 2020 by DiJo.", 10, $y, $leftPanel_w - 38, 28, 0x0200)
GUICtrlSetFont(-1, 8, Default, Default, "Segoe UI", 5) ; 5 = Clear Type
GUICtrlSetColor(-1, $cText)

Global $y = $topPanel_h
GUICtrlCreateLabel(" FNKC Pack", 52, $y, $leftPanel_w - 52, 32, 0x0200)
GUICtrlSetFont(-1, 12, 600, Default, "Segoe UI", 5) ; 5 = Clear Type
GUICtrlSetColor(-1, $cText)

$y += 50
Global $vDashboard = GUICtrlCreateLabel("Mode 1", 38, $y, $leftPanel_w - 38, 32, 0x0200)
GUICtrlSetOnEvent(-1, "DashboardEvent")
GUICtrlSetFont(-1, 11, 600, Default, "Segoe UI", 5) ; 5 = Clear Type
GUICtrlSetColor(-1, $cTextA)
GUICtrlSetCursor(-1, 0)
$lastMenu = $vDashboard
$y += 32
Global $vWallet = GUICtrlCreateLabel("Mode 2", 38, $y, $leftPanel_w - 38, 32, 0x0200)
GUICtrlSetOnEvent(-1, "WalletEvent")
GUICtrlSetFont(-1, 11, 600, Default, "Segoe UI", 5) ; 5 = Clear Type
GUICtrlSetColor(-1, $cText)
GUICtrlSetCursor(-1, 0)
$y += 32
Global $vMessages = GUICtrlCreateLabel("Mode 3", 38, $y, $leftPanel_w - 38, 32, 0x0200)
GUICtrlSetOnEvent(-1, "MessagesEvent")
GUICtrlSetFont(-1, 11, 600, Default, "Segoe UI", 5) ; 5 = Clear Type
GUICtrlSetColor(-1, $cText)
GUICtrlSetCursor(-1, 0)

$y = ($topPanel_h + 50)
Global $vIndicator = GUICtrlCreateLabel("", 0, $y, 4, 32)
GUICtrlSetBkColor(-1, $cTextA)

$x = $contentPanel_x + 10
$y = $contentPanel_y + 15
Global $iHostName = GUICtrlCreateInput("", $x + 200, $y + 10, 180, 21)
Global $Button1 = GUICtrlCreateButton("Ping", $x, $y + 80, 267, 43)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") ;задаем стиль элементу выше
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x0E0C2E)
GUICtrlSetOnEvent(-1, "_Didshit1")
Global $Button2 = GUICtrlCreateButton("ChangePass", $x + 310, $y + 80, 267, 43)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") ;задаем стиль элементу выше
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x0E0C2E)
GUICtrlSetOnEvent(-1, "_Didshit2")
Global $Button3 = GUICtrlCreateButton("Start", $x, $y + 140, 267, 43) ;создаем кнопку подключения
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") ;задаем стиль элементу выше
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x0E0C2E)

Global $Checkbox1 = GUICtrlCreateCheckbox("", $x + 273, $y + 95, 12, 12)
Global $Checkbox2 = GUICtrlCreateCheckbox("", $x + 293, $y + 95, 12, 12)

GUISetState() ; Show GUI
Global $rHostName
While True
    Sleep(10)
WEnd

Func DashboardEvent()
    If $lastMenu <> $vDashboard Then
        Local $CGP = ControlGetPos($UI, '', $vDashboard)
        GUICtrlSetPos($vIndicator, 0, $CGP[1])
        GUICtrlSetColor($vDashboard, $cTextA)
        GUICtrlSetColor($lastMenu, $cText)
        $lastMenu = $vDashboard
        GUICtrlSetState($Button1, $GUI_SHOW)
        GUICtrlSetState($Button2, $GUI_SHOW)
        GUICtrlSetState($Checkbox1, $GUI_SHOW)
        GUICtrlSetState($Checkbox2, $GUI_SHOW)
        ConsoleWrite(1)
    EndIf
EndFunc   ;==>DashboardEvent

Func WalletEvent()
    If $lastMenu <> $vWallet Then
        Local $CGP = ControlGetPos($UI, '', $vWallet)
        GUICtrlSetPos($vIndicator, 0, $CGP[1])
        GUICtrlSetColor($vWallet, $cTextA)
        GUICtrlSetColor($lastMenu, $cText)
        $lastMenu = $vWallet
        GUICtrlSetState($Button1, $GUI_HIDE)
        GUICtrlSetState($Button2, $GUI_HIDE)
        GUICtrlSetState($Checkbox1, $GUI_HIDE)
        GUICtrlSetState($Checkbox2, $GUI_HIDE)
        ConsoleWrite(1)
    EndIf
EndFunc   ;==>WalletEvent

Func MessagesEvent()
    If $lastMenu <> $vMessages Then
        Local $CGP = ControlGetPos($UI, '', $vMessages)
        GUICtrlSetPos($vIndicator, 0, $CGP[1])
        GUICtrlSetColor($vMessages, $cTextA)
        GUICtrlSetColor($lastMenu, $cText)
        $lastMenu = $vMessages
        GUICtrlSetState($Button1, $GUI_HIDE)
        GUICtrlSetState($Button2, $GUI_HIDE)
        GUICtrlSetState($Checkbox1, $GUI_HIDE)
        GUICtrlSetState($Checkbox2, $GUI_HIDE)
        ConsoleWrite(1)
    EndIf
EndFunc   ;==>MessagesEvent

Func _Didshit1()
    $rHostName = GUICtrlRead($iHostName)
    Run(@ComSpec & ' /c C:\Windows\System32\Ping.exe ' & $rHostName & ' -t')
EndFunc   ;==>_Didshit1

Func _Didshit2()
    $rHostName = GUICtrlRead($iHostName)
    RunWait(@ComSpec & ' /c PsPasswd \\' & $rHostName & ' Администратор Mik35')
EndFunc   ;==>_Didshit2

Func Terminate()
    GUIDelete($UI)
    Exit
EndFunc   ;==>Terminate

Func Minimize()
    GUISetState(@SW_MINIMIZE, $UI)
EndFunc   ;==>Minimize

Func Topmost()
    If $isOnTop = False Then
        WinSetOnTop($UI, Default, 1)
        $isOnTop = True
    Else
        WinSetOnTop($UI, Default, 0)
        $isOnTop = False
    EndIf
EndFunc   ;==>Topmost

Func CalcPercent($vPercent, $vInt) ; Calculate percent % :)
    Return $vPercent * $vInt / 100
EndFunc   ;==>CalcPercent
начни вникать в справку и искать по форуму.
То есть GUICtrlSetOnEvent присваивается каждому элементу(кнопка или чекбокс),затем на этой основе создается функция?
Сообщение автоматически объединено:

То есть GUICtrlSetOnEvent присваивается каждому элементу(кнопка или чекбокс),затем на этой основе создается функция?
Да, все круто, разобрался как делать)пасибо огромнейшее :acute: :acute: :acute:
 
Последнее редактирование:
Верх