Problem mit Radios (nicht das Gerät) ;)

  • Hi

    ich habe folgened GUI:

    Spoiler anzeigen
    [autoit]


    $Maindialog = GUICreate($titel, 220, 330, -1, -1)
    GUISetBkColor(0xffffff)
    GUICtrlCreateLabel($titel & " v." & $version, 50, 5, 150, 25, $WS_DISABLED)
    $aktion = GUICtrlCreateGroup("Aktion", 50, 30, 105, 170)
    $shutdown = GUICtrlCreateRadio("Ausschalten", 65, 55, 85, 20)
    GUICtrlSetTip(-1, "Computer Ausschalten")
    $ruhezustand = GUICtrlCreateRadio("Ruhezustand", 65, 85, 85, 20)
    GUICtrlSetTip(-1, "Computer wird in den Ruhezustand gefahren")
    $standby = GUICtrlCreateRadio("Standby", 65, 115, 85, 20)
    GUICtrlSetTip(-1, "Computer wird in den Standby-Modus gefahren")
    $reboot = GUICtrlCreateRadio("Neu starten", 65, 145, 85, 20)
    GUICtrlSetTip(-1, "Computer wird Neu gestartet")
    $logoff = GUICtrlCreateRadio("Abmelden", 65, 175, 85, 20)
    GUICtrlSetTip(-1, "Benutzer wird abgemeldet")
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlCreateGroup("Aktionszeit", 10, 210, 200, 70)
    $uhrzeit_redio = GUICtrlCreateRadio("um: ", 25, 225, 40, 20)
    GUICtrlSetTip(-1, "Zeitpunkt, zu dem die gewünschte Aktion ausgeführt werden soll")
    $timer_redio = GUICtrlCreateRadio("in: ", 25, 255, 40, 20)
    GUICtrlSetTip(-1, "Zeitpunkt, zu dem die gewünschte Aktion ausgeführt werden soll")
    $stunden = GUICtrlCreateInput("", 75, 242, 30, 20)
    GUICtrlCreateLabel(":", 111, 244, 10, 20)
    $minuten = GUICtrlCreateInput("", 120, 242, 30, 20)
    GUICtrlCreateLabel(":", 155, 244, 10, 20)
    $sekunden = GUICtrlCreateInput("", 165, 242, 30, 20)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $aktion_ausfuehren = GUICtrlCreateButton(" OK ", 95, 290)
    GUISetState(@SW_SHOW, $Maindialog)

    [/autoit]


    wie lese ich nun aus auf welchem Wert die Radios stehen?

    hab es bis jetzt so gelöst:

    Spoiler anzeigen
    [autoit]


    Case $shutdown
    $aktion = "Ausschalten"
    Case $ruhezustand
    $aktion = "Ruhezustand"
    Case $standby
    $aktion = "Standby"
    Case $reboot
    $aktion = "Neu starten"
    Case $logoff
    $aktion = "Abmelden"
    Case $uhrzeit_redio
    $modus = "Uhrzeit"
    Case $timer_redio
    $modus = "Timer"

    [/autoit]


    das ganze gefällt mir aber nich so. Hat wer ne Lösung?

    Gruß Michi26206

    PS: Frohe Weihnachten

    2 Mal editiert, zuletzt von Michi26206 (29. Dezember 2008 um 16:07)

  • Ich kann mir nicht vorstellen, das man das so machen kann, da es ja eigentlich für Buttons geeignet ist.
    Ich würde es in die normale Schleife setzten und da dann:

    [autoit]

    If GUICtrlRead($Radio) = 1 Then;Ich bin mir nicht sicher ob 1 Checked war ;)
    $aktion = "deine Aktion"
    Endif

    [/autoit]
  • Hab dir mal eine Starthilfe gemacht:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $titel = 'Shutdown-Manager'
    $version = '1.0'

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $Maindialog = GUICreate($titel, 220, 330, -1, -1)
    GUISetBkColor(0xffffff)
    GUICtrlCreateLabel($titel & " v." & $version, 50, 5, 150, 25, $WS_DISABLED)
    $aktion = GUICtrlCreateGroup("Aktion", 50, 30, 105, 170)
    $shutdown = GUICtrlCreateRadio("Ausschalten", 65, 55, 85, 20)
    GUICtrlSetState($shutdown, $GUI_CHECKED) ;vorbelegen
    Global $Aktion = "Ausschalten" ;vorbelegen
    GUICtrlSetTip(-1, "Computer Ausschalten")
    $ruhezustand = GUICtrlCreateRadio("Ruhezustand", 65, 85, 85, 20)
    GUICtrlSetTip(-1, "Computer wird in den Ruhezustand gefahren")
    $standby = GUICtrlCreateRadio("Standby", 65, 115, 85, 20)
    GUICtrlSetTip(-1, "Computer wird in den Standby-Modus gefahren")
    $reboot = GUICtrlCreateRadio("Neu starten", 65, 145, 85, 20)
    GUICtrlSetTip(-1, "Computer wird Neu gestartet")
    $logoff = GUICtrlCreateRadio("Abmelden", 65, 175, 85, 20)
    GUICtrlSetTip(-1, "Benutzer wird abgemeldet")
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlCreateGroup("Aktionszeit", 10, 210, 200, 70)
    $uhrzeit_redio = GUICtrlCreateRadio("um: ", 25, 225, 40, 20)
    GUICtrlSetTip(-1, "Zeitpunkt, zu dem die gewünschte Aktion ausgeführt werden soll")
    $timer_redio = GUICtrlCreateRadio("in: ", 25, 255, 40, 20)
    GUICtrlSetTip(-1, "Zeitpunkt, zu dem die gewünschte Aktion ausgeführt werden soll")
    $stunden = GUICtrlCreateInput("", 75, 242, 30, 20)
    GUICtrlCreateLabel(":", 111, 244, 10, 20)
    $minuten = GUICtrlCreateInput("", 120, 242, 30, 20)
    GUICtrlCreateLabel(":", 155, 244, 10, 20)
    $sekunden = GUICtrlCreateInput("", 165, 242, 30, 20)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $aktion_ausfuehren = GUICtrlCreateButton(" OK ", 95, 290)
    GUISetState(@SW_SHOW, $Maindialog)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = GUIGetMsg()
    Switch $msg
    Case $aktion_ausfuehren
    Switch $Aktion
    Case "Ausschalten"
    ;~ Shutdown(9)
    Case "Ruhezustand"
    ;~ Shutdown(64)
    Case "Standby"
    ;~ Shutdown(32)
    Case "Neu starten"
    ;~ Shutdown(2)
    Case "Abmelden"
    ;~ Shutdown(0)
    EndSwitch
    Case $shutdown
    $Aktion = "Ausschalten"
    Case $ruhezustand
    $Aktion = "Ruhezustand"
    Case $standby
    $Aktion = "Standby"
    Case $reboot
    $Aktion = "Neu starten"
    Case $logoff
    $Aktion = "Abmelden"
    Case $uhrzeit_redio
    $modus = "Uhrzeit"
    Case $timer_redio
    $modus = "Timer"
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    Sleep(20)
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit]

    Das nächste Mal poste lieber das ganze Skript. Ist nicht sehr toll wenn man alles selber zusammenstöpseln muss!

  • Hi,

    danke. Ich poste meine Codes net so gern komplett sonst klaut sie mir wieder wer. Ist mir nämlich schon passiert.

    Aber ok hier mal mein Code. Ist aber noch nicht final. Muss den Code noch n bisschen aufräumen. Werde es aber wahrscheinlich heute fertigstellen:

    Spoiler anzeigen
    [autoit]


    #cs --------------------------------------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    Shutdown-Manager.exe (C) by Michi26206 - Programm zum geziehlten Auschalten, Abmelden etc. des PCs

    [/autoit] [autoit][/autoit] [autoit]

    #ce --------------------------------------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    #AutoIt3Wrapper_icon=shutdown.ico
    #AutoIt3Wrapper_Res_Description=by Michi26206
    #AutoIt3Wrapper_Res_Legalcopyright=by Michi26206
    #AutoIt3Wrapper_Res_Fileversion=1.0 ;Achtung bei Aktualiesierung schaun !!!!!

    [/autoit] [autoit][/autoit] [autoit]

    #Include <GUIConstantsEx.au3>
    #Include <WindowsConstants.au3>
    #Include <ButtonConstants.au3>
    #Include <Misc.au3>
    #Include <Sound.au3>
    #Include <Date.au3>

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Opt("GUICloseOnESC", 1) ; ESC drücken beendet Programm nicht
    Opt("TrayAutoPause", 0) ; das Script nicht pausieren, wenn auf das Tray-Icon geklickt wird
    Opt("TrayMenuMode", 1) ; kein Defaul-Tray-Menu
    Opt("MustDeclareVars", 1) ; Variablen müssen deklariert werden
    Opt("TrayOnEventMode",1)

    [/autoit] [autoit][/autoit] [autoit]

    ;Vriablen anfang
    Global $titel = "Shutdown-Manager", $version = "1.0", $quell_code_zeilen = "196", $Maindialog, $easteregg, $uhrzeit_redio, $timer_redio, $stunden, $minuten, $sekunden, $aktions_zeit, $shutdown, $ruhezustand, $standby, $reboot, $logoff, $nMsg, $img, $sound, $IE, $aktion, $text_um, $text_in, $aktion_ausfuehren, $aktion, $modus = "-1", $timer, $timer_differenz, $timer_tick, $countdown_show = "1", $gui_read_stunden, $gui_read_minuten, $gui_read_sekunden
    Dim $umwandeln[4], $aktionszeitpunkt[3], $countdown[4]
    ; Vriablen ende

    [/autoit] [autoit][/autoit] [autoit]

    ;--------------------------------------------------------
    ;--------------- Anfang GUI Maindialog ------------------
    ;--------------------------------------------------------
    $Maindialog = GUICreate($titel, 220, 330, -1, -1)
    GUISetBkColor(0xffffff)
    GUICtrlCreateLabel($titel & " v." & $version, 50, 5, 150, 25, $WS_DISABLED)
    $easteregg = GUICtrlCreatePic("", 0, 0, 10, 10)
    $aktion = GUICtrlCreateGroup("Aktion", 50, 30, 105, 170)
    $shutdown = GUICtrlCreateRadio("Ausschalten", 65, 55, 85, 20)
    GUICtrlSetTip(-1, "Computer Ausschalten")
    $ruhezustand = GUICtrlCreateRadio("Ruhezustand", 65, 85, 85, 20)
    GUICtrlSetTip(-1, "Computer wird in den Ruhezustand gefahren")
    $standby = GUICtrlCreateRadio("Standby", 65, 115, 85, 20)
    GUICtrlSetTip(-1, "Computer wird in den Standby-Modus gefahren")
    $reboot = GUICtrlCreateRadio("Neu starten", 65, 145, 85, 20)
    GUICtrlSetTip(-1, "Computer wird Neu gestartet")
    $logoff = GUICtrlCreateRadio("Abmelden", 65, 175, 85, 20)
    GUICtrlSetTip(-1, "Benutzer wird abgemeldet")
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlCreateGroup("Aktionszeit", 10, 210, 200, 70)
    $uhrzeit_redio = GUICtrlCreateRadio("um: ", 25, 225, 40, 20)
    GUICtrlSetTip(-1, "Zeitpunkt, zu dem die gewünschte Aktion ausgeführt werden soll")
    $timer_redio = GUICtrlCreateRadio("in: ", 25, 255, 40, 20)
    GUICtrlSetTip(-1, "Zeitpunkt, zu dem die gewünschte Aktion ausgeführt werden soll")
    $stunden = GUICtrlCreateInput("", 75, 242, 30, 20)
    GUICtrlCreateLabel(":", 111, 244, 10, 20)
    $minuten = GUICtrlCreateInput("", 120, 242, 30, 20)
    GUICtrlCreateLabel(":", 155, 244, 10, 20)
    $sekunden = GUICtrlCreateInput("", 165, 242, 30, 20)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $aktion_ausfuehren = GUICtrlCreateButton(" OK ", 95, 290)
    TrayCreateItem($titel & " v." & $version)
    TrayCreateItem("")
    TrayCreateItem("About")
    TrayItemSetOnEvent(-1,"About")
    TrayCreateItem("Exit")
    TrayItemSetOnEvent(-1,"Close")
    TraySetState()
    GUISetState(@SW_SHOW, $Maindialog)
    ;--------------------------------------------------------
    ;----------------- Ende GUI Maindialog ------------------
    ;--------------------------------------------------------
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    HotKeySet( "!q")
    Exit
    Case $shutdown
    $aktion = "Ausschalten"
    Case $ruhezustand
    $aktion = "Ruhezustand"
    Case $standby
    $aktion = "Standby"
    Case $reboot
    $aktion = "Neu starten"
    Case $logoff
    $aktion = "Abmelden"
    Case $uhrzeit_redio
    $modus = "Uhrzeit"
    Case $timer_redio
    $modus = "Timer"
    Case $aktion_ausfuehren
    $gui_read_stunden = GUICtrlRead($stunden)
    $gui_read_minuten = GUICtrlRead($minuten)
    $gui_read_sekunden = GUICtrlRead($sekunden)
    GUISetState(@SW_HIDE, $Maindialog)
    HotKeySet( "!q", "Close")
    If $aktion = 5 Or $modus = -1 Or $gui_read_stunden = "" Or $gui_read_minuten = "" Or $gui_read_sekunden = "" Then
    MsgBox(64, "Error","Sie müssen eine Auswahl treffen")
    GUISetState(@SW_SHOW, $Maindialog)
    EndIf
    If $modus = "Uhrzeit" And $gui_read_stunden > 23 Or $gui_read_minuten > 59 Or $gui_read_sekunden > 59 Then
    MsgBox(64, "Error","Es ist ein Gültigkeitsfehler aufgetreten." & @CRLF & "Es gilt:" & @CRLF & "Stunden müssen kleiner 24 sein." & @CRLF & "Minuten müssen kleiner 60 sein." & @CRLF & "Sekunden müssen kleiner 60 sein.")
    GUISetState(@SW_SHOW, $Maindialog)
    EndIf
    If $aktion <> 5 And $modus = "Uhrzeit" And $gui_read_stunden <> "" And $gui_read_minuten <> "" And $gui_read_sekunden <> "" And $gui_read_stunden < 23 And $gui_read_minuten < 59 And $gui_read_sekunden < 59 Then
    $aktionszeitpunkt[1] = $gui_read_stunden & ":" & $gui_read_minuten & ":" & $gui_read_sekunden
    MsgBox(64, "Info", "Aktion " & $aktion & " " & @CRLF & "Wird ausgeführt um: " & $aktionszeitpunkt[1] & @CRLF & @CRLF & "Achtung: Das Programm kann absofort nur noch über ALT + Q oder das Traymenü beendet werden!", 5)
    If $countdown_show = 1 Then
    $aktionszeitpunkt[1] = _TimeToTicks($gui_read_stunden, $gui_read_minuten, $gui_read_sekunden)
    $aktionszeitpunkt[2] = _TimeToTicks(@HOUR,@MIN,@SEC)
    _TicksToTime($aktionszeitpunkt[1] - $aktionszeitpunkt[2], $countdown[1], $countdown[2], $countdown[3])
    SplashTextOn($aktion & " in", $countdown[1] & ":" & $countdown[2] & ":" & $countdown[3], 300, 70, @DesktopWidth-310, 10, 18, Default, 40)
    WinActivate($aktion & " in")
    EndIf
    Do
    If $countdown_show = 1 Then
    $aktionszeitpunkt[2] = _TimeToTicks(@HOUR,@MIN,@SEC)
    _TicksToTime($aktionszeitpunkt[1] - $aktionszeitpunkt[2], $countdown[1], $countdown[2], $countdown[3])
    ControlSetText($aktion & " in", "", "Static1", $countdown[1] & ":" & $countdown[2] & ":" & $countdown[3])
    EndIf
    Sleep(100)
    Until $aktionszeitpunkt[1] = @HOUR & ":" & @MIN & ":" & @SEC
    SplashOff()
    Switch $aktion
    Case "Ausschalten"
    Shutdown(1)
    Exit
    Case "Ruhezustand"
    Shutdown(64)
    Exit
    Case "Standby"
    Shutdown(32)
    Exit
    Case "Neu starten"
    Shutdown(2)
    Exit
    Case "Abmelden"
    Shutdown(0)
    Exit
    EndSwitch
    ElseIf $aktion <> 5 And $Modus = "Timer" And $gui_read_stunden <> "" And $gui_read_minuten <> "" And $gui_read_sekunden <> "" Then
    $timer = TimerInit()
    $aktionszeitpunkt[1] = _TimeToTicks($gui_read_stunden, $gui_read_minuten, $gui_read_sekunden)
    MsgBox(64, "Info", "Aktion " & $aktion & " " & @CRLF & "Wird in " & $gui_read_stunden & " Stunden " & $gui_read_minuten & " Minuten und " & $gui_read_sekunden & " Sekunden." & @CRLF & @CRLF & "Achtung: Das Programm kann absofort nur noch über ALT + Q oder das Traymenü beendet werden!", 5)
    If $countdown_show = 1 Then
    _TicksToTime($aktionszeitpunkt[1] - $timer_tick, $countdown[1], $countdown[2], $countdown[3])
    SplashTextOn($aktion & " in", $countdown[1] & ":" & $countdown[2] & ":" & $countdown[3], 300, 70, @DesktopWidth-310, 10, 18, Default, 40)
    WinActivate($aktion & " in")
    EndIf
    Do
    _TicksToTime(TimerDiff($timer), $umwandeln[1], $umwandeln[2], $umwandeln[3])
    $timer_tick = _TimeToTicks($umwandeln[1], $umwandeln[2], $umwandeln[3])
    If $countdown_show = 1 Then
    $aktionszeitpunkt[2] = _TimeToTicks($gui_read_stunden, $gui_read_minuten, $gui_read_sekunden)
    _TicksToTime($aktionszeitpunkt[2] - $timer_tick, $countdown[1], $countdown[2], $countdown[3])
    ControlSetText($aktion & " in", "", "Static1", $countdown[1] & ":" & $countdown[2] & ":" & $countdown[3])
    EndIf
    Sleep(100)
    Until $timer_tick = $aktionszeitpunkt[1]
    SplashOff()
    Switch $aktion
    Case "Ausschalten"
    Shutdown(1)
    Exit
    Case "Ruhezustand"
    Shutdown(64)
    Exit
    Case "Standby"
    Shutdown(32)
    Exit
    Case "Neu starten"
    Shutdown(2)
    Exit
    Case "Abmelden"
    Shutdown(0)
    Exit
    EndSwitch
    EndIf
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func Close()
    HotKeySet( "!q")
    Exit
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func About()
    MsgBox(64, $titel & " v." & $version & " About", $titel & " v. " & $version & @CRLF & "Autor: Michi26206" & @CRLF & $quell_code_zeilen & " Zeilen Quellcod")
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit]

    Achtung: Copyright by Michi26206
    Gruß Michi26206

    PS: Was haltet ihr von dem Code?

    4 Mal editiert, zuletzt von Michi26206 (29. Dezember 2008 um 16:02)