• hab mir mal ein timer programm geschrieben das ich eine zeit lang häuft (immer zum ausmachen des pcs) benutzt habe. habs jetzt um einiges verbessert (so gut wie ich konnte!). könnt mir ja ma feedback geben wie es euch gefällt un so.
    und ach ja könnt mir vill jemand sagen wie ich das so bekomme das wenn ich den info button klicke ein fenster zum browsen eines pfades kommt un der ausgewählte pfad dann in die inputbox kommt? wusst einfach nich wie man das macht


    [autoit]

    #include <ButtonConstants.au3>
    #include <ComboConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=D:\Scripts\koda_1.7.2.0\Forms\timersleep.kxf
    $Form1_1 = GUICreate("Timer", 440, 316, 194, 129)
    $inputhour = GUICtrlCreateInput("", 8, 16, 73, 21)
    $inputmin = GUICtrlCreateInput("", 8, 48, 73, 21)
    $labelhour = GUICtrlCreateLabel("Geben Sie ein nach wie vielen Stunden der Timer beendet werden soll.", 88, 20, 339, 17)
    $Label1 = GUICtrlCreateLabel("Geben Sie ein nach wie vielen Minute der Timer beendet werden soll.", 88, 52, 339, 17)
    $Settings = GUICtrlCreateGroup("Settings", 8, 112, 417, 145)
    $soundplay = GUICtrlCreateRadio("Play Sound", 16, 136, 73, 25)
    $turnfeaturesradio = GUICtrlCreateRadio("Turn Features", 16, 176, 89, 25)
    $msgfeatures = GUICtrlCreateRadio("Messagebox Features", 16, 216, 129, 25)
    $soundpfad = GUICtrlCreateInput("", 96, 136, 265, 21)
    $turnfeaturescombo = GUICtrlCreateCombo("Herunterfahren", 112, 176, 249, 25)
    GUICtrlSetData(-1, "Standby|Ruhezustand")
    $msgfeaturesinput = GUICtrlCreateInput("", 152, 216, 209, 21)
    $Button1 = GUICtrlCreateButton("Info", 376, 216, 33, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Set Pfad", 368, 136, 49, 25, $WS_GROUP)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $timerstart = GUICtrlCreateButton("TIME IT", 104, 264, 241, 41, $WS_GROUP)
    $Label2 = GUICtrlCreateLabel("oder geben sie eine Uhrzeit ein", 8, 80, 150, 17)
    $inathour = GUICtrlCreateInput("", 160, 80, 25, 21)
    $Label3 = GUICtrlCreateLabel(":", 192, 80, 7, 17)
    $inatmin = GUICtrlCreateInput("", 200, 80, 25, 21)
    $Label4 = GUICtrlCreateLabel("Uhr", 232, 80, 21, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg

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

    Case $GUI_EVENT_CLOSE
    Exit

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

    Case $timerstart
    $h = GUICtrlRead($inputhour)
    $min = GUICtrlRead($inputmin)
    $h = $h*60*60
    $min = $min*60
    $athour = GUICtrlRead($inathour)
    $atmin = GUICtrlRead($inatmin)
    $setread1 = GUICtrlRead($soundplay)
    $setread2 = GUICtrlRead($turnfeaturesradio)
    $setread3 = GUICtrlRead($msgfeatures)
    $timermsgtxt= GUICtrlRead($msgfeaturesinput)
    $x = guictrlread($turnfeaturescombo)
    $sound_pfad = GUICtrlRead($soundpfad)
    WinSetState ( "Timer", "", @SW_HIDE )
    if $setread1 = 1 Then
    timer_soundplay()
    Exit
    EndIf
    if $setread2 = 1 Then
    timer_sleep()
    Exit
    EndIf
    if $setread3 = 1 Then
    timermsg()
    Exit
    EndIf

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

    case $Button1
    MsgBox(64,"Info","Gebe hier einen Text ein der nach ablaufen der Zeit angezeigt werden soll, z.B. eine Erinnerung/Tätigkeit.")
    Case $Button2
    $sounddatei = FileOpenDialog("Wähle dein Sound","","Lieder (*.mp3;*.wav)")
    GUICtrlSetData($soundpfad,$sounddatei)

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

    EndSwitch
    WEnd

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

    func timermsg()
    timermsgattime()
    For $zeit = $h+$min to 0 Step -1
    sleep(1000)
    Next
    MsgBox(1,"Timer",$timermsgtxt)
    EndFunc

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

    func timermsgattime()
    if $h = '' Then
    if $min = '' Then
    while 1
    if @hour = $athour Then
    while 1
    if @min = $atmin Then
    MsgBox(1,"Timer",$timermsgtxt)
    exit
    EndIf
    sleep(1000*3)
    wend
    EndIf
    sleep(1000*5)
    WEnd
    EndIf
    EndIf
    EndFunc

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

    func timer_sleep()
    timer_sleep_time()
    if $x = "Herunterfahren" Then
    $aus = 1
    elseif $x = "Standby" Then
    $aus = 32
    ElseIf $x ="Ruhezustand" Then
    $aus = 64
    EndIf
    For $zeit = $h+$min to 0 Step -1
    sleep(1000)
    Next
    Shutdown ($aus)
    EndFunc

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

    func timer_sleep_time()
    if $h = '' Then
    if $min = '' Then
    while 1
    if @hour = $athour Then
    while 1
    if @min = $atmin Then
    if $x = "Herunterfahren" Then
    $aus = 1
    elseif $x = "Standby" Then
    $aus = 32
    ElseIf $x ="Ruhezustand" Then
    $aus = 64
    EndIf
    Shutdown ($aus)
    exit
    EndIf
    sleep(1000*3)
    wend
    EndIf
    sleep(1000*5)
    WEnd
    EndIf
    EndIf
    EndFunc

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

    func timer_soundplay()
    timer_soundplay_time()
    For $zeit = $h+$min to 0 Step -1
    sleep(1000)
    Next
    SoundPlay($sound_pfad,1)
    EndFunc

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

    func timer_soundplay_time()
    if $h = '' Then
    if $min = '' Then
    while 1
    if @hour = $athour Then
    while 1
    if @min = $atmin Then
    SoundPlay($sound_pfad,1)
    exit
    EndIf
    sleep(1000*3)
    wend
    EndIf
    sleep(1000*5)
    WEnd
    EndIf
    EndIf
    EndFunc

    [/autoit]
  • sieht schon gut aus und funktioniert auch, habs mal mit ner msgbox und 2 minuten probiert

    für die pfadangabe empfehle ich dir
    FileOpenDialog bzw FileSelectFolderjenachdem ob du eine Datei oder einen Pfad brauchst
    und dazu Guictrlsetdata, damit kannst du es in ne inputbox schreiben.

    kleiner verbesserungsvorschlag:
    statt der inputbox für die zeitangabe ein updown verwenden:
    zum beispiel so:

    [autoit]

    $InputLevel1 = GUICtrlCreateInput("0", 19, 90, 48, 25, 0x2001)
    $UpDownLevel1 = GUICtrlCreateUpdown($InputLevel1)
    GUICtrlSetLimit($UpDownLevel1, 23, 0)

    [/autoit]

    sind jetz 3 zeilen, dafür haste 2 kleine buttons zum erhöhen und verringeren der zahlen die drinstehn.
    es können nur zahlen reingeschrieben werden
    und du kannst sie mit guictrlsetlimit begrenzen, in meinem beispiel zwischen 0 und 23
    (würde ja sinn machen sonst kann das ding ewig laufen)

    ansonsten gute arbeit ;)

  • jop fileopendialog war genau das was ich gebraucht habe thx! jetzt ist es einfacher wenn man ne sounddatei abspielen lassen will nach ablauf der zeit

    habs nomma bissle geändert jetzt kann mans sogar als wecker nehmen wenn pc an is :P
    aber jetzt hab ich glaube viel zu viele überflüssige zeilen aber hab mcih au beeilt wills nämlich noch morgen als wecker testen :P
    so nomma schnell umgeändert. jetzt ist der wecker nicht mehr so genau aber es entlastet die cpu mehr als vorher