InputFelder berechnen

  • Hallo AutoIt Comm,
    wiedermal stehe ich vor einem Rätsel, es geht darum ein InputFeld zu berechnen.

    Ich schick am besten mal den Code, ist ein wenig bescheiden zu erklären.

    [autoit]

    #include <GUIConstantsEx.au3>
    #include <GUIConstants.au3>
    ;---------------------------------;

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

    #Region ### START Koda GUI section ### Form=
    $calculator = GUICreate("Boss Calculator", 311, 201, 193, 125)
    $bosse = GUICtrlCreateCombo("Boss Wählen", 8, 8, 153, 25)
    GUICtrlSetData(-1, "Aden Fregatte|Ghoetheborg|Bartolomew|Hawkins|General Charlie Will|General Cruz")
    $nextrespawn = GUICtrlCreateLabel("Nächster Spawn:", 168, 56, 101, 17)
    GUICtrlSetFont(-1, 8, 800, 4, "MS Sans Serif")
    $respawntime = GUICtrlCreateLabel("Respawn Zeit:", 168, 8, 86, 17)
    GUICtrlSetFont(-1, 8, 800, 4, "MS Sans Serif")
    $time = GUICtrlCreateLabel("Zeit:", 8, 40, 30, 17)
    GUICtrlSetFont(-1, 8, 800, 4, "MS Sans Serif")
    $date = GUICtrlCreateLabel("Datum:", 8, 72, 44, 17)
    GUICtrlSetFont(-1, 8, 800, 4, "MS Sans Serif")
    $calc = GUICtrlCreateButton("Berechnen", 8, 168, 107, 25, 0)

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

    $time1 = GUICtrlCreateInput("00:00:00", 64, 40, 57, 21)
    GUICtrlSetData(-1, @HOUR&":"&@MIN&":"&@SEC)
    $date1 = GUICtrlCreateInput("TT.MM", 64, 72, 57, 21)
    GUICtrlSetData(-1, @MDAY&"."&@MON)
    ; -------^---Dort wird die Aktuelle PC Zeit&Datum ausgelesen---^------- ;

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

    $respawntime1 = GUICtrlCreateInput("00:00:00", 168, 32, 73, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $spawnnext = GUICtrlCreateInput("00:00:00", 168, 80, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $spawnnext1 = GUICtrlCreateInput("00:00:00", 168, 104, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $spawnnext2 = GUICtrlCreateInput("00:00:00", 168, 128, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $spawnnext3 = GUICtrlCreateInput("00:00:00", 168, 152, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $spawnnext4 = GUICtrlCreateInput("00:00:00", 168, 176, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $ttmm = GUICtrlCreateInput("TT.MM", 232, 80, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $ttmm1 = GUICtrlCreateInput("TT.MM", 232, 104, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $ttmm2 = GUICtrlCreateInput("TT.MM", 232, 128, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $ttmm3 = GUICtrlCreateInput("TT.MM", 232, 152, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $ttmm4 = GUICtrlCreateInput("TT.MM", 232, 176, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    ; ------^--Dort sollen die neuen daten eingetragen werden --^------ ;

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

    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $msg = GUIGetMsg(1)
    Select

    Case $msg[0] = $bosse ; <---- Hier wird der gewünschte Boss mit der jeweiligen ReSpawn Zeit rausgesucht
    If GUICtrlRead($bosse) = "Aden Fregatte" Then
    GUICtrlSetData($respawntime1, "6:50:00")
    ElseIf GUICtrlRead($bosse) = "Ghoetheborg" Then
    GUICtrlSetData($respawntime1, "6:50:00")
    ElseIf GUICtrlRead($bosse) = "Bartolomew" Then
    GUICtrlSetData($respawntime1, "10:04:00")
    ElseIf GUICtrlRead($bosse) = "Hawkins" Then
    GUICtrlSetData($respawntime1, "09:04:00")
    ElseIf GUICtrlRead($bosse) = "General Cruz" Then
    GUICtrlSetData($respawntime1, "19:20:00")
    ElseIf GUICtrlRead($bosse) = "General Charlie Will" Then
    GUICtrlSetData($respawntime1, "13:45:00")
    Else
    GUICtrlSetData($respawntime1, "00:00:00")
    EndIf

    Case $msg[0] = $calc
    GUICtrlSetData($spawnnext, (GUICtrlRead($respawntime1))) ; <--- dort soll er die neue Zeit berechnen

    Case $msg[0] = $GUI_EVENT_CLOSE
    If $msg[1] = $calculator Then Exit

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

    EndSelect
    WEnd

    [/autoit]

    Also er soll das neue Datum+Zeit in die Input felder eintragen. Aber wenn er $respawntime1 mit $time1 addieren soll, spuckt er mir entweder eine Fehlermeldung raus, oder da steht ne Dicke "0".

    Hoffe Ihr könnt mir helfen.

    mfg.

  • Ich frage mich was daran Bot ähnlich sein soll.
    Er rechnet nur Zeiten aus wann mal ein Boss kommt, und es gibt viele Calculatoren die mit Excel und OpenOffice Calc geschrieben sind.

    Wie gesagt, er rechnet nur Zeiten aus, mehr nicht.

    Er hackt sich nicht in ürgend nen Server ein, oder guckt ob die HP leiste voll oder fast leer ist.

    Er rechnet nur ^^ nicht mehr nicht weniger

    EDIT: nochmal. hatte in zeile 75 was vergessen

    [autoit]

    Case $msg[0] = $calc
    GUICtrlSetData($spawnnext, (GUICtrlRead($respawntime1) + GUICtrlRead($time1))) ; <--- dort soll er die neue Zeit berechnen

    [/autoit]

    So sieht Zeile 75 richtig aus

  • Hö? und wo wird was gerechnet im Skript?

    Was genau soll ausgerechnet werden?

    Mal ein Lösungsansatz für 6:50 addieren.

    1 Schritt _Dateadd 6 Stunden
    2 Schritt _Dateadd 50min
    (wies auf einmal geht weiss ich grad nicht)

    • Offizieller Beitrag

    Hi,

    Autoit kann auch nicht einfach zwei Uhrzeiten addieren. Das musst du Autoit beibringen :thumbup:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <GUIConstants.au3>
    ;---------------------------------;

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

    #Region ### START Koda GUI section ### Form=
    $calculator = GUICreate("Boss Calculator", 311, 201, 193, 125)
    $bosse = GUICtrlCreateCombo("Boss Wählen", 8, 8, 153, 25)
    GUICtrlSetData(-1, "Aden Fregatte|Ghoetheborg|Bartolomew|Hawkins|General Charlie Will|General Cruz")
    $nextrespawn = GUICtrlCreateLabel("Nächster Spawn:", 168, 56, 101, 17)
    GUICtrlSetFont(-1, 8, 800, 4, "MS Sans Serif")
    $respawntime = GUICtrlCreateLabel("Respawn Zeit:", 168, 8, 86, 17)
    GUICtrlSetFont(-1, 8, 800, 4, "MS Sans Serif")
    $time = GUICtrlCreateLabel("Zeit:", 8, 40, 30, 17)
    GUICtrlSetFont(-1, 8, 800, 4, "MS Sans Serif")
    $date = GUICtrlCreateLabel("Datum:", 8, 72, 44, 17)
    GUICtrlSetFont(-1, 8, 800, 4, "MS Sans Serif")
    $calc = GUICtrlCreateButton("Berechnen", 8, 168, 107, 25, 0)

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

    $time1 = GUICtrlCreateInput("00:00:00", 64, 40, 57, 21)
    GUICtrlSetData(-1, @HOUR & ":" & @MIN & ":" & @SEC)
    $date1 = GUICtrlCreateInput("TT.MM", 64, 72, 57, 21)
    GUICtrlSetData(-1, @MDAY & "." & @MON)
    ; -------^---Dort wird die Aktuelle PC Zeit&Datum ausgelesen---^------- ;

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

    $respawntime1 = GUICtrlCreateInput("12:02:02", 168, 32, 73, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $spawnnext = GUICtrlCreateInput("00:00:00", 168, 80, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $spawnnext1 = GUICtrlCreateInput("00:00:00", 168, 104, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $spawnnext2 = GUICtrlCreateInput("00:00:00", 168, 128, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $spawnnext3 = GUICtrlCreateInput("00:00:00", 168, 152, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $spawnnext4 = GUICtrlCreateInput("00:00:00", 168, 176, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $ttmm = GUICtrlCreateInput("TT.MM", 232, 80, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $ttmm1 = GUICtrlCreateInput("TT.MM", 232, 104, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $ttmm2 = GUICtrlCreateInput("TT.MM", 232, 128, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $ttmm3 = GUICtrlCreateInput("TT.MM", 232, 152, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $ttmm4 = GUICtrlCreateInput("TT.MM", 232, 176, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    ; ------^--Dort sollen die neuen daten eingetragen werden --^------ ;

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

    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $msg = GUIGetMsg(1)
    Select

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

    Case $msg[0] = $bosse ; <---- Hier wird der gewünschte Boss mit der jeweiligen ReSpawn Zeit rausgesucht
    If GUICtrlRead($bosse) = "Aden Fregatte" Then
    GUICtrlSetData($respawntime1, "6:50:00")
    ElseIf GUICtrlRead($bosse) = "Ghoetheborg" Then
    GUICtrlSetData($respawntime1, "6:50:00")
    ElseIf GUICtrlRead($bosse) = "Bartolomew" Then
    GUICtrlSetData($respawntime1, "10:04:00")
    ElseIf GUICtrlRead($bosse) = "Hawkins" Then
    GUICtrlSetData($respawntime1, "09:04:00")
    ElseIf GUICtrlRead($bosse) = "General Cruz" Then
    GUICtrlSetData($respawntime1, "19:20:00")
    ElseIf GUICtrlRead($bosse) = "General Charlie Will" Then
    GUICtrlSetData($respawntime1, "13:45:00")
    Else
    GUICtrlSetData($respawntime1, "00:00:00")
    EndIf

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

    Case $msg[0] = $calc
    ConsoleWrite(GUICtrlRead($respawntime1) & @CRLF)
    ConsoleWrite(GUICtrlRead($time1) & @CRLF)
    GUICtrlSetData($spawnnext, AddTime(GUICtrlRead($respawntime1), GUICtrlRead($time1))) ; <--- dort soll er die neue Zeit berechnen

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

    Case $msg[0] = $GUI_EVENT_CLOSE
    If $msg[1] = $calculator Then Exit

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

    EndSelect
    WEnd

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

    Func AddTime($time1, $TIME2)
    Local $MIN_CARRY = 0, $HOUR_CARRY = 0
    $SPLIT1 = StringSplit($time1, ":")
    $SPLIT2 = StringSplit($TIME2, ":")
    $SEC = Number($SPLIT1[3]) + Number($SPLIT2[3])
    While $SEC >= 60
    $SEC -= 60
    $MIN_CARRY += 1
    WEnd
    $MIN = Number($SPLIT1[2]) + Number($SPLIT2[2])
    $MIN += $MIN_CARRY
    While $MIN >= 60
    $MIN -= 60
    $HOUR_CARRY += 1
    WEnd
    $HOUR = Number($SPLIT1[1]) + Number($SPLIT2[1])
    $HOUR += $HOUR_CARRY
    If $HOUR >= 24 Then
    ;~ Return "ERROR"
    $HOUR -= 24
    ;~ Else
    $HOUR = String($HOUR)
    $MIN = String($MIN)
    $SEC = String($SEC)
    If StringLen($HOUR) < 2 Then $HOUR = "0" & $HOUR
    If StringLen($MIN) < 2 Then $MIN = "0" & $MIN
    If StringLen($SEC) < 2 Then $SEC = "0" & $SEC
    Return $HOUR & ":" & $MIN & ":" & $SEC
    EndIf
    EndFunc ;==>AddTime

    [/autoit]

    Mega

  • Spoiler anzeigen
    [autoit]


    #include <GUIConstantsEx.au3>
    #include <GUIConstants.au3>
    #include <Date.au3>
    ;---------------------------------;

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

    #Region ### START Koda GUI section ### Form=
    $calculator = GUICreate("Boss Calculator", 311, 201, 193, 125)
    $bosse = GUICtrlCreateCombo("Boss Wählen", 8, 8, 153, 25)
    GUICtrlSetData(-1, "Aden Fregatte|Ghoetheborg|Bartolomew|Hawkins|General Charlie Will|General Cruz")
    $nextrespawn = GUICtrlCreateLabel("Nächster Spawn:", 168, 56, 101, 17)
    GUICtrlSetFont(-1, 8, 800, 4, "MS Sans Serif")
    $respawntime = GUICtrlCreateLabel("Respawn Zeit:", 168, 8, 86, 17)
    GUICtrlSetFont(-1, 8, 800, 4, "MS Sans Serif")
    $time = GUICtrlCreateLabel("Zeit:", 8, 40, 30, 17)
    GUICtrlSetFont(-1, 8, 800, 4, "MS Sans Serif")
    $date = GUICtrlCreateLabel("Datum:", 8, 72, 44, 17)
    GUICtrlSetFont(-1, 8, 800, 4, "MS Sans Serif")
    $calc = GUICtrlCreateButton("Berechnen", 8, 168, 107, 25, 0)

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

    $time1 = GUICtrlCreateInput("00:00:00", 64, 40, 57, 21)
    GUICtrlSetData(-1, @HOUR&":"&@MIN&":"&@SEC)
    $date1 = GUICtrlCreateInput("JJ/MM/TT", 64, 72, 57, 21)
    GUICtrlSetData(-1, @YEAR&"/"&@MON & "/"&@MDAY)
    ; -------^---Dort wird die Aktuelle PC Zeit&Datum ausgelesen---^------- ;

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

    $respawntime1 = GUICtrlCreateInput("00:00:00", 168, 32, 73, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $spawnnext = GUICtrlCreateInput("00:00:00", 168, 80, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $spawnnext1 = GUICtrlCreateInput("00:00:00", 168, 104, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $spawnnext2 = GUICtrlCreateInput("00:00:00", 168, 128, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $spawnnext3 = GUICtrlCreateInput("00:00:00", 168, 152, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $spawnnext4 = GUICtrlCreateInput("00:00:00", 168, 176, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $ttmm = GUICtrlCreateInput("JJ/MM/TT", 232, 80, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $ttmm1 = GUICtrlCreateInput("TT.MM", 232, 104, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $ttmm2 = GUICtrlCreateInput("TT.MM", 232, 128, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $ttmm3 = GUICtrlCreateInput("TT.MM", 232, 152, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $ttmm4 = GUICtrlCreateInput("TT.MM", 232, 176, 57, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    ; ------^--Dort sollen die neuen daten eingetragen werden --^------ ;

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

    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $msg = GUIGetMsg(1)
    Select

    Case $msg[0] = $bosse ; <---- Hier wird der gewünschte Boss mit der jeweiligen ReSpawn Zeit rausgesucht
    If GUICtrlRead($bosse) = "Aden Fregatte" Then
    GUICtrlSetData($respawntime1, "6:50:00")
    ElseIf GUICtrlRead($bosse) = "Ghoetheborg" Then
    GUICtrlSetData($respawntime1, "6:50:00")
    ElseIf GUICtrlRead($bosse) = "Bartolomew" Then
    GUICtrlSetData($respawntime1, "10:04:00")
    ElseIf GUICtrlRead($bosse) = "Hawkins" Then
    GUICtrlSetData($respawntime1, "09:04:00")
    ElseIf GUICtrlRead($bosse) = "General Cruz" Then
    GUICtrlSetData($respawntime1, "19:20:00")
    ElseIf GUICtrlRead($bosse) = "General Charlie Will" Then
    GUICtrlSetData($respawntime1, "13:45:00")
    Else
    GUICtrlSetData($respawntime1, "00:00:00")
    EndIf

    Case $msg[0] = $calc
    local $sdate = stringsplit(_ADD(), " ")
    GUICtrlSetData($spawnnext, $sdate[2] ); <--- dort soll er die neue Zeit berechnen
    GUICtrlSetData($ttmm, $sdate[1] )
    Case $msg[0] = $GUI_EVENT_CLOSE
    If $msg[1] = $calculator Then Exit

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

    EndSelect
    WEnd

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

    Func _ADD()
    $stime = stringsplit(guictrlread($respawntime1), ":")
    $addhour = _DateAdd("h", $stime[1], GUICtrlRead($date1) & " "& GUICtrlRead($time1))
    $addminutes = _DateAdd("m", $stime[2], $addhour)
    return $addminutes
    endfunc

    [/autoit]

    Eine Lösung mit _Dateadd.

    Hab mich etwas drumrumgemogelt das Format des Datums in ein _Dateadd konformes umzuwandlen.
    Kannste dir ja noch anpassen.