Einen Timmer in ein label einbauen

  • Hallo,

    ich bin neu in autoit und möchte einen Timer programmieren der von 10 sekunden runterzählt und wen er angekommen ist, dan soll eine msgbox erscheinen. bis jetzt aber ohne erfolg.
    code:

    [autoit]

    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Timer", 214, 74, 192, 124)
    GUISetFont(24, 800, 0, "MS Sans Serif")
    $Label1 = GUICtrlCreateLabel("Timer", 0, 0, 210, 68)
    GUICtrlSetFont(-1, 30, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    GUICtrlSetData($Label1,$timer)
    EndSwitch
    WEnd

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

    Func timer()
    TimerDiff(1000)
    EndFunc

    [/autoit]


    könnt ihr hier mir sagen wie man den Timer programmiert?

    lg TimmlanHD

  • Etwa so sollte es funktionieren:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Timer", 214, 74, 192, 124)
    GUISetFont(24, 800, 0, "MS Sans Serif")
    $Label1 = GUICtrlCreateLabel("Timer", 0, 0, 210, 68)
    GUICtrlSetFont(-1, 30, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    AdlibRegister ("timer", 1000)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

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

    Func timer()
    Local Static $i = 10
    $i -= 1
    GUICtrlSetData ($Label1, $i)
    If $i = 0 Then
    AdlibUnRegister ("timer")
    MsgBox (0, "title", "text")
    EndIf
    EndFunc

    [/autoit]
  • Vielen dank!
    gibt es hier im forum einen thanks button? oder einen buton de den anderen was gutes tut?

    lg timm

  • Okay, das was du Gepostet hast läuft perfekt!

    jetzt habe ich einen Mathe Trainer Prpgrammiert und versucht wenn er unten den countdown durch hat, das er eine neue Zahl generieren soll.
    Dies klappt aber leider nur einmal, eil der Countdown, dann ins Minus geht :/


    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #region ### START Koda GUI section ### Form=
    $Form1_1 = GUICreate("Mathetrainer v1.2.5", 434, 585, 192, 121)
    GUISetBkColor(0xFFFFFF)
    $Label2 = GUICtrlCreateLabel("", 16, 40, 4, 4)
    $Label3 = GUICtrlCreateLabel("zahl", 16, 48, 55, 17)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label4 = GUICtrlCreateLabel("+", 72, 48, 10, 17)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label5 = GUICtrlCreateLabel("zahl", 96, 48, 47, 17)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label6 = GUICtrlCreateLabel("=", 160, 48, 26, 17)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("Neue zahl generieren", 8, 80, 177, 25)
    $Label1 = GUICtrlCreateLabel("Mathetrainer", 8, 8, 248, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Input1 = GUICtrlCreateInput("", 192, 48, 81, 21)
    $Button2 = GUICtrlCreateButton("Lösung anzeigen", 192, 80, 177, 25)
    $Label7 = GUICtrlCreateLabel("Lösung", 376, 88, 55, 17)
    $Button3 = GUICtrlCreateButton("aufgabe checken", 280, 48, 89, 25)
    $Label8 = GUICtrlCreateLabel("Mathetrainer", 8, 152, 274, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Label9 = GUICtrlCreateLabel("_____________________________________________________________________", 0, 112, 418, 17)
    $Label10 = GUICtrlCreateLabel("Zahl", 16, 192, 51, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label11 = GUICtrlCreateLabel("-", 72, 192, 9, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label12 = GUICtrlCreateLabel("Zahl", 88, 192, 51, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label13 = GUICtrlCreateLabel("=", 152, 192, 13, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Input2 = GUICtrlCreateInput("", 192, 192, 81, 21)
    $Button4 = GUICtrlCreateButton("Aufgabe checken", 280, 192, 91, 25)
    $Button5 = GUICtrlCreateButton("Neue Zahl generieren", 0, 224, 185, 25)
    $Button6 = GUICtrlCreateButton("Lösung anzeigen", 200, 224, 169, 25)
    $Label14 = GUICtrlCreateLabel("Lösung", 376, 224, 39, 17)
    $Label15 = GUICtrlCreateLabel("_____________________________________________________________________", 0, 264, 418, 17)
    $Label16 = GUICtrlCreateLabel("Mathetrainer", 0, 304, 354, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Label17 = GUICtrlCreateLabel("Zahl", 8, 344, 35, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label18 = GUICtrlCreateLabel("*", 72, 344, 10, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label19 = GUICtrlCreateLabel("Zahl", 88, 344, 59, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label20 = GUICtrlCreateLabel("=", 152, 344, 13, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Input3 = GUICtrlCreateInput("", 192, 344, 81, 21)
    $Button7 = GUICtrlCreateButton("Aufgabe Checken", 280, 344, 97, 25)
    $Button8 = GUICtrlCreateButton("Neue Zahl generieren", 0, 376, 193, 25)
    $Button9 = GUICtrlCreateButton("Lösung anzeigen", 208, 376, 169, 25)
    $Label21 = GUICtrlCreateLabel("Lösung", 384, 376, 39, 17)
    $Label22 = GUICtrlCreateLabel("____________________________________________________________________", 0, 416, 412, 17)
    $Label23 = GUICtrlCreateLabel("Mathetrainer", 0, 456, 252, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Label24 = GUICtrlCreateLabel("Zahl", 16, 496, 35, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label25 = GUICtrlCreateLabel("/", 80, 496, 8, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label26 = GUICtrlCreateLabel("Zahl", 96, 496, 35, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label27 = GUICtrlCreateLabel("=", 152, 496, 13, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Input4 = GUICtrlCreateInput("", 192, 496, 81, 21)
    $Button10 = GUICtrlCreateButton("Aufgabe checken", 280, 496, 97, 25)
    $Button11 = GUICtrlCreateButton("Lösung anzeigen", 208, 520, 169, 25)
    $Button12 = GUICtrlCreateButton("Neue Zahl generieren", 0, 520, 193, 25)
    $Label28 = GUICtrlCreateLabel("Lösung", 384, 528, 39, 17)
    $Label29 = GUICtrlCreateLabel("© Copyright by TimmLanHD", 8, 552, 199, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label30 = GUICtrlCreateLabel("Zeit", 376, 48, 31, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label31 = GUICtrlCreateLabel("Zeit", 376, 192, 31, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label32 = GUICtrlCreateLabel("Zeit", 384, 344, 31, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label33 = GUICtrlCreateLabel("Zeit", 384, 496, 31, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###

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

    MsgBox(0, "Info", "Generieren sie zuerst eine Zahl und klicken, wenn es notwendig, ist auf Lösung anzeigen", 3)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    Case $Button8;3 zahl generieren
    $randomzahl1 = randomzahl1() ;Zahl generieren
    GUICtrlSetData($Label17, $randomzahl1)
    $randomzahl1 = randomzahl1()
    GUICtrlSetData($Label19, $randomzahl1)

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

    Case $Button1;1zahl generieren

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

    $randomzahl1 = randomzahl1() ;Zahl generieren
    GUICtrlSetData($Label5, $randomzahl1)
    $randomzahl1 = randomzahl1()
    GUICtrlSetData($Label3, $randomzahl1)
    AdlibRegister ("timer", 1000)

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

    Case $Button2;1 zusammenrechnen
    GUICtrlSetData($Label7, GUICtrlRead($Label3) + GUICtrlRead($Label5)) ;zusammenrechnen


    Case $Button4;2 geschriebenes checken
    If Not GUICtrlRead($Input2, GUICtrlRead($Label10) - GUICtrlRead($Label12)) Then
    MsgBox(0, "Fehler", "Streng dein kopf mehr an ;-)")
    EndIf

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

    Case $Button5;2 zahl generieren
    $randomzahl1 = randomzahl1() ;Zahl generieren
    GUICtrlSetData($Label10, $randomzahl1)
    $randomzahl1 = randomzahl1()
    GUICtrlSetData($Label12, $randomzahl1)

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

    Case $Button6;2 zusammenrechnen
    GUICtrlSetData($Label14, GUICtrlRead($Label10) - GUICtrlRead($Label12)) ;zusammenrechnen

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

    Case $Button3;1 geschriebenes checken
    If Not GUICtrlRead($Input1, GUICtrlRead($Label3) + GUICtrlRead($Label5)) Then
    MsgBox(0, "Fehler", "Streng dein kopf mehr an ;-)")
    EndIf

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

    Case $Button7;3 geschriebenes checken
    If Not GUICtrlRead($Input3, GUICtrlRead($Label17) - GUICtrlRead($Label19)) Then
    MsgBox(0, "Fehler", "Streng dein kopf mehr an ;-)")
    EndIf

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

    Case $Button9;3 zusammenrechnen
    GUICtrlSetData($Label21, GUICtrlRead($Label17) * GUICtrlRead($Label19)) ;zusammenrechnen
    Case $Button12;4 Zahl generieren

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

    $randomzahl1 = randomzahl1() ;Zahl generieren
    GUICtrlSetData($Label24, $randomzahl1)
    $randomzahl1 = randomzahl1()
    GUICtrlSetData($Label26, $randomzahl1)

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

    Case $Button11;4 zusammenrechnen

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

    GUICtrlSetData($Label28, GUICtrlRead($Label24) / GUICtrlRead($Label26)) ;zusammenrechnen

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

    Case $Button10;3 geschriebenes checken
    If Not GUICtrlRead($Input3, GUICtrlRead($Label24) - GUICtrlRead($Label26)) Then
    MsgBox(0, "Fehler", "Streng dein kopf mehr an ;-)")

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

    EndIf
    EndSwitch
    WEnd

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

    Func randomzahl1()
    Return Random(1, 100, 1)
    EndFunc ;==>randomzahl1

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

    Func timer()
    Local Static $i = 10
    $i -= 1
    GUICtrlSetData ($Label1, $i)
    If $i = 0 Then
    AdlibUnRegister ("timer")
    $randomzahl1 = randomzahl1() ;Zahl generieren
    GUICtrlSetData($Label5, $randomzahl1)
    $randomzahl1 = randomzahl1()
    GUICtrlSetData($Label3, $randomzahl1)
    EndIf
    EndFunc
    EndFunc ;==>timer

    [/autoit]

    #######################################
    Jetzt bräuchte ich eine Funktion, dass, wenn er fertig ist mit den runterzählen den Timer neu geniert auf 10, (weil bei einer schleife habe ich das problem das er auf der countdown zahl 9 stehen bleibt :/

    lg

  • Als erstes, bitte warte einfach bis dein Thema freigeschaltet wird, du brauchst das nicht mehrmals zu posten ;). Falls du aus versehen einen Beitrag erstellst (...), bzw. diesen Beitrag löschen willst, klick einfach auf bearbeiten und dann auf löschen. Das ist übersichtlicher und macht mehr Sinn als den ursprünglichen Inhalt durch etwas irrelevantes zu ersetzen...
    Zu deinem aktuellen Problem:
    Du brauchst keine extra Funktion dafür. Du hast bereits eine If-Abfrage deren Inhalt immer ausgeführt wird wenn der Timer den Wert 0 erreicht. Du willst, dass in diesem Moment der Timer (also die Variable $i) wieder auf den Wert 10 zurückgesetzt wird. Also weist du einfach der Variable $i, welche deinen Timer repräsentiert den ursprünglichen Wert 10 zu. $i = 10 ist doch nicht so schwer oder? ;)

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #region ### START Koda GUI section ### Form=
    $Form1_1 = GUICreate("Mathetrainer v1.2.5", 434, 585, 192, 121)
    GUISetBkColor(0xFFFFFF)
    $Label2 = GUICtrlCreateLabel("", 16, 40, 4, 4)
    $Label3 = GUICtrlCreateLabel("zahl", 16, 48, 55, 17)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label4 = GUICtrlCreateLabel("+", 72, 48, 10, 17)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label5 = GUICtrlCreateLabel("zahl", 96, 48, 47, 17)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label6 = GUICtrlCreateLabel("=", 160, 48, 26, 17)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("Neue zahl generieren", 8, 80, 177, 25)
    $Label1 = GUICtrlCreateLabel("Mathetrainer", 8, 8, 248, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Input1 = GUICtrlCreateInput("", 192, 48, 81, 21)
    $Button2 = GUICtrlCreateButton("Lösung anzeigen", 192, 80, 177, 25)
    $Label7 = GUICtrlCreateLabel("Lösung", 376, 88, 55, 17)
    $Button3 = GUICtrlCreateButton("aufgabe checken", 280, 48, 89, 25)
    $Label8 = GUICtrlCreateLabel("Mathetrainer", 8, 152, 274, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Label9 = GUICtrlCreateLabel("_____________________________________________________________________", 0, 112, 418, 17)
    $Label10 = GUICtrlCreateLabel("Zahl", 16, 192, 51, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label11 = GUICtrlCreateLabel("-", 72, 192, 9, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label12 = GUICtrlCreateLabel("Zahl", 88, 192, 51, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label13 = GUICtrlCreateLabel("=", 152, 192, 13, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Input2 = GUICtrlCreateInput("", 192, 192, 81, 21)
    $Button4 = GUICtrlCreateButton("Aufgabe checken", 280, 192, 91, 25)
    $Button5 = GUICtrlCreateButton("Neue Zahl generieren", 0, 224, 185, 25)
    $Button6 = GUICtrlCreateButton("Lösung anzeigen", 200, 224, 169, 25)
    $Label14 = GUICtrlCreateLabel("Lösung", 376, 224, 39, 17)
    $Label15 = GUICtrlCreateLabel("_____________________________________________________________________", 0, 264, 418, 17)
    $Label16 = GUICtrlCreateLabel("Mathetrainer", 0, 304, 354, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Label17 = GUICtrlCreateLabel("Zahl", 8, 344, 35, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label18 = GUICtrlCreateLabel("*", 72, 344, 10, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label19 = GUICtrlCreateLabel("Zahl", 88, 344, 59, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label20 = GUICtrlCreateLabel("=", 152, 344, 13, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Input3 = GUICtrlCreateInput("", 192, 344, 81, 21)
    $Button7 = GUICtrlCreateButton("Aufgabe Checken", 280, 344, 97, 25)
    $Button8 = GUICtrlCreateButton("Neue Zahl generieren", 0, 376, 193, 25)
    $Button9 = GUICtrlCreateButton("Lösung anzeigen", 208, 376, 169, 25)
    $Label21 = GUICtrlCreateLabel("Lösung", 384, 376, 39, 17)
    $Label22 = GUICtrlCreateLabel("____________________________________________________________________", 0, 416, 412, 17)
    $Label23 = GUICtrlCreateLabel("Mathetrainer", 0, 456, 252, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Label24 = GUICtrlCreateLabel("Zahl", 16, 496, 35, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label25 = GUICtrlCreateLabel("/", 80, 496, 8, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label26 = GUICtrlCreateLabel("Zahl", 96, 496, 35, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label27 = GUICtrlCreateLabel("=", 152, 496, 13, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Input4 = GUICtrlCreateInput("", 192, 496, 81, 21)
    $Button10 = GUICtrlCreateButton("Aufgabe checken", 280, 496, 97, 25)
    $Button11 = GUICtrlCreateButton("Lösung anzeigen", 208, 520, 169, 25)
    $Button12 = GUICtrlCreateButton("Neue Zahl generieren", 0, 520, 193, 25)
    $Label28 = GUICtrlCreateLabel("Lösung", 384, 528, 39, 17)
    $Label29 = GUICtrlCreateLabel("© Copyright by TimmLanHD", 8, 552, 199, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label30 = GUICtrlCreateLabel("Zeit", 376, 48, 31, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label31 = GUICtrlCreateLabel("Zeit", 376, 192, 31, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label32 = GUICtrlCreateLabel("Zeit", 384, 344, 31, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label33 = GUICtrlCreateLabel("Zeit", 384, 496, 31, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###

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

    MsgBox(0, "Info", "Generieren sie zuerst eine Zahl und klicken, wenn es notwendig, ist auf Lösung anzeigen", 3)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    Case $Button8;3 zahl generieren
    $randomzahl1 = randomzahl1() ;Zahl generieren
    GUICtrlSetData($Label17, $randomzahl1)
    $randomzahl1 = randomzahl1()
    GUICtrlSetData($Label19, $randomzahl1)

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

    Case $Button1;1zahl generieren

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

    $randomzahl1 = randomzahl1() ;Zahl generieren
    GUICtrlSetData($Label5, $randomzahl1)
    $randomzahl1 = randomzahl1()
    GUICtrlSetData($Label3, $randomzahl1)
    AdlibRegister("timer", 1000)

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

    Case $Button2;1 zusammenrechnen
    GUICtrlSetData($Label7, GUICtrlRead($Label3) + GUICtrlRead($Label5)) ;zusammenrechnen

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

    Case $Button4;2 geschriebenes checken
    If Not GUICtrlRead($Input2, GUICtrlRead($Label10) - GUICtrlRead($Label12)) Then
    MsgBox(0, "Fehler", "Streng dein kopf mehr an ;-)")
    EndIf

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

    Case $Button5;2 zahl generieren
    $randomzahl1 = randomzahl1() ;Zahl generieren
    GUICtrlSetData($Label10, $randomzahl1)
    $randomzahl1 = randomzahl1()
    GUICtrlSetData($Label12, $randomzahl1)

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

    Case $Button6;2 zusammenrechnen
    GUICtrlSetData($Label14, GUICtrlRead($Label10) - GUICtrlRead($Label12)) ;zusammenrechnen

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

    Case $Button3;1 geschriebenes checken
    If Not GUICtrlRead($Input1, GUICtrlRead($Label3) + GUICtrlRead($Label5)) Then
    MsgBox(0, "Fehler", "Streng dein kopf mehr an ;-)")
    EndIf

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

    Case $Button7;3 geschriebenes checken
    If Not GUICtrlRead($Input3, GUICtrlRead($Label17) - GUICtrlRead($Label19)) Then
    MsgBox(0, "Fehler", "Streng dein kopf mehr an ;-)")
    EndIf

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

    Case $Button9;3 zusammenrechnen
    GUICtrlSetData($Label21, GUICtrlRead($Label17) * GUICtrlRead($Label19)) ;zusammenrechnen
    Case $Button12;4 Zahl generieren

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

    $randomzahl1 = randomzahl1() ;Zahl generieren
    GUICtrlSetData($Label24, $randomzahl1)
    $randomzahl1 = randomzahl1()
    GUICtrlSetData($Label26, $randomzahl1)

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

    Case $Button11;4 zusammenrechnen

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

    GUICtrlSetData($Label28, GUICtrlRead($Label24) / GUICtrlRead($Label26)) ;zusammenrechnen

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

    Case $Button10;3 geschriebenes checken
    If Not GUICtrlRead($Input3, GUICtrlRead($Label24) - GUICtrlRead($Label26)) Then
    MsgBox(0, "Fehler", "Streng dein kopf mehr an ;-)")

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

    EndIf
    EndSwitch
    WEnd

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

    Func randomzahl1()
    Return Random(1, 100, 1)
    EndFunc ;==>randomzahl1

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

    Func timer()
    Local Static $i = 10
    $i -= 1
    GUICtrlSetData($Label1, $i)
    If $i = 0 Then
    $i = 10
    AdlibUnRegister("timer")
    $randomzahl1 = randomzahl1() ;Zahl generieren
    GUICtrlSetData($Label5, $randomzahl1)
    $randomzahl1 = randomzahl1()
    GUICtrlSetData($Label3, $randomzahl1)
    EndIf
    EndFunc ;==>timer

    [/autoit]
  • Okay, das geht schonmal ganz gut.

    jetzt bin ich nur noch dabei wenn bei dem Countdown bei 0 angekommen ist, das er eine neue zahl gneriert.
    dies klappt leider ganicht :/ da er denn wieder ins minus geht!

    Spoiler anzeigen
    [autoit]

    Func timer()
    Local Static $i = 10
    $i -= 1
    GUICtrlSetData($Label30, $i)
    If $i = 0 Then
    If $i = 10 Then
    $randomzahl1 = randomzahl1() ;Zahl generieren
    GUICtrlSetData($Label3, $randomzahl1)
    $randomzahl1 = randomzahl1()
    GUICtrlSetData($Label5, $randomzahl1)
    EndIf
    EndIf

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

    EndFunc ;==>timer

    [/autoit]
  • Ich habe jetzt nicht wirklich Lust, den kompletten Code anzuschauen... So in etwa sollte es aber passen:

    Spoiler anzeigen
    [autoit]

    Func timer()
    Local Static $i = 10
    $i -= 1
    GUICtrlSetData($Label30, $i)
    If $i = 10 Then
    $randomzahl1 = randomzahl1() ;Zahl generieren
    GUICtrlSetData($Label3, $randomzahl1)
    $randomzahl1 = randomzahl1()
    GUICtrlSetData($Label5, $randomzahl1)
    ElseIf $i = 0 Then
    $i = randomzahl1()
    EndIf
    EndFunc ;==>timer

    [/autoit]