StopUhr Wie würdet ihrs machen?

  • puh ne ganz schöne menge neu informationen für mich drinnen^^ . Aber bei mir müsste das im prinzip ja irgend wie rückwärts laufen xD

  • weil mir gerade so langweilig war, hab ich angefangen diese stopuhr zu scripten =)
    ok, ich hab 2 probleme:


    • falls es geht... wenn die sekunden ($s) bei 00 anfangen, und dann $i + 1 gerechnet wird, dass nicht 1, sondern 01 dasteht. is aber nur wegen der optik
    • das eigentliche problem: wenn man "start" drückt, fängt es an (eigt. klar :D ), und ich weiß nicht wie ich das anstellen soll dass das script aufhört wenn ich auf "Stop" drücke
    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    Global $s=0, $m=0, $h=0
    Opt("GUIOnEventMode", 1)
    #Region ### START Koda GUI section ### Form=c:\dokumente und einstellungen\****\desktop\stopuhr\koda.kxf
    $Form1_1 = GUICreate("Stopuhr", 345, 305, 193, 125)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_end")
    $Group1 = GUICtrlCreateGroup("", 24, 24, 289, 249)
    $stund = GUICtrlCreateLabel("00", 128, 88, 22, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $minut = GUICtrlCreateLabel("00", 160, 88, 22, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel(":", 184, 88, 8, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label4 = GUICtrlCreateLabel(":", 152, 88, 8, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $sekund = GUICtrlCreateLabel("00", 192, 88, 22, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label6 = GUICtrlCreateLabel("Stopuhr", 128, 40, 93, 34)
    GUICtrlSetFont(-1, 18, 400, 0, "Century Gothic")
    $start = GUICtrlCreateButton("Start", 112, 128, 49, 25, 0)
    GUICtrlSetOnEvent($start, "_start")
    $stop = GUICtrlCreateButton("Stop", 184, 128, 49, 25, 0)
    GUICtrlSetOnEvent($stop, "_stop")
    $pause = GUICtrlCreateButton("Pause", 112, 168, 49, 25, 0)
    GUICtrlSetOnEvent($pause, "_pause")
    $weiter = GUICtrlCreateButton("Weiter", 184, 168, 49, 25, 0)
    GUICtrlSetOnEvent($weiter, "_weiter")
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    While 1
    Sleep(100)
    WEnd
    Func _start()
    While 1
    Sleep(1000)
    $s = $s + 1
    GUICtrlSetData($sekund, $s)
    If $s = 60 Then
    $m = $m + 1
    $s = 0
    GUICtrlSetData($minut, $m)
    If $m = 60 Then
    $h = $h + 1
    $m = 0
    GUICtrlSetData($stund, $h)
    EndIf
    EndIf
    WEnd
    EndFunc
    Func _stop()
    MsgBox(0,"", "Die Zeit war: " & $h & ":" & $m & ":" & $s & ".")
    EndFunc
    Func _pause()
    ;noch keinen plan =)
    EndFunc
    Func _weiter()
    ;ebenfalls
    EndFunc

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

    Func _end()
    Exit
    EndFunc

    [/autoit]

    ich hoffe ich hab das mal einigermaßen "normal" erklärt ^^

  • Den Fenster code habe ich auch schon^^:

    Spoiler anzeigen
    [autoit]


    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <ListBoxConstants.au3>

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

    #Region ### START Koda GUI section ### Form=E:\MartinK\Coding und Mapping\AutoIT\Koda-Vorlagen (.kxf - Daten)\Gamers-Watch beta 0.01.kxf
    $Form1 = GUICreate("Gamers-Watch", 300, 571, 311, 143)
    GUISetBkColor(0x808080)
    $Label1 = GUICtrlCreateLabel("Heutiges Datum:", 16, 130, 83, 17)
    $Input1 = GUICtrlCreateInput("", 104, 128, 41, 21)
    $Input2 = GUICtrlCreateInput("", 152, 128, 41, 21)
    $Input3 = GUICtrlCreateInput("", 200, 128, 57, 21)
    $Label2 = GUICtrlCreateLabel("Jetztige Uhrzeit:", 20, 162, 79, 17)
    $Input4 = GUICtrlCreateInput("", 104, 160, 33, 21)
    $Input5 = GUICtrlCreateInput("", 152, 160, 41, 21)
    $Label3 = GUICtrlCreateLabel("Uhr", 200, 162, 21, 17)
    $Label4 = GUICtrlCreateLabel(":", 142, 202, 7, 17)
    $Label5 = GUICtrlCreateLabel("Stopzeit:", 104, 192, 76, 24)
    GUICtrlSetFont(-1, 12, 800, 4, "MS Sans Serif")
    $Input6 = GUICtrlCreateInput("", 24, 224, 65, 32)
    GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
    $Input7 = GUICtrlCreateInput("", 112, 224, 65, 32)
    GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
    $Input8 = GUICtrlCreateInput("", 200, 224, 65, 32)
    GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
    $Label6 = GUICtrlCreateLabel(":", 184, 226, 10, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Label7 = GUICtrlCreateLabel(":", 96, 226, 10, 28)
    GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
    $Label8 = GUICtrlCreateLabel("Stunden", 28, 256, 60, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Label9 = GUICtrlCreateLabel("Minuten", 118, 256, 57, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Label10 = GUICtrlCreateLabel("Sekunden", 198, 256, 73, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("Start", 32, 288, 91, 41, 0)
    $Button2 = GUICtrlCreateButton("Stop", 160, 288, 91, 41, 0)
    $Button3 = GUICtrlCreateButton("Pause", 32, 352, 91, 41, 0)
    $Button4 = GUICtrlCreateButton("Weiter", 160, 352, 91, 41, 0)
    $Button5 = GUICtrlCreateButton("Zeit speichern", 32, 416, 91, 41, 0)
    $Button6 = GUICtrlCreateButton("Log. öffnen", 160, 416, 91, 41, 0)
    $Checkbox1 = GUICtrlCreateCheckbox("Kommentar mit abspeichern", 32, 472, 161, 17)
    $Label11 = GUICtrlCreateLabel("Kommentar:", 32, 496, 60, 17)
    $Input9 = GUICtrlCreateInput("", 32, 520, 225, 21)
    $Pic1 = GUICtrlCreatePic("C:\Dokumente und Einstellungen\MartinK\Desktop\ÜberBild.jpg", 0, 0, 300, 116, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $MenuItem1 = GUICtrlCreateMenu("Menu")
    $MenuItem2 = GUICtrlCreateMenuItem("Exit", $MenuItem1)
    $MenuItem3 = GUICtrlCreateMenuItem("Optionen", $MenuItem1)
    $MenuItem8 = GUICtrlCreateMenuItem("Starte TS", $MenuItem1)
    $MenuItem4 = GUICtrlCreateMenu("Hilfe")
    $MenuItem5 = GUICtrlCreateMenuItem("Hilfe", $MenuItem4)
    $MenuItem6 = GUICtrlCreateMenuItem("Versionshinweise", $MenuItem4)
    $MenuItem7 = GUICtrlCreateMenuItem("Credits", $MenuItem4)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    #Region ### START Koda GUI section ### Form=E:\MartinK\Coding und Mapping\AutoIT\Koda-Vorlagen (.kxf - Daten)\LogAnzeigeFenster.kxf
    $Form2 = GUICreate("Logs", 231, 317, 261, 140)
    GUISetBkColor(0x716F64)
    $List1 = GUICtrlCreateList("", 8, 40, 214, 266)
    $Label1 = GUICtrlCreateLabel("Logs:", 88, 8, 55, 28)
    GUICtrlSetFont(-1, 14, 800, 4, "MS Sans Serif")
    #EndRegion ### END Koda GUI section ###
    #Region ### START Koda GUI section ### Form=E:\MartinK\Coding und Mapping\AutoIT\Koda-Vorlagen (.kxf - Daten)\OptionsFensterGamersWatch.kxf
    $Form3 = GUICreate("Optionen", 218, 114, 303, 219)
    GUISetBkColor(0x716F64)
    $Checkbox1 = GUICtrlCreateCheckbox("TS-Funktion aktivieren", 8, 8, 137, 17)
    $Input1 = GUICtrlCreateInput("", 8, 48, 121, 21)
    $Label1 = GUICtrlCreateLabel("Teamspeack.exe Pfad:", 8, 30, 114, 17)
    $Button1 = GUICtrlCreateButton("Pfad wählen", 136, 46, 75, 25, 0)
    $Button2 = GUICtrlCreateButton("Einstellung speichern", 24, 80, 139, 25, 0)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $msg = GUIGetMsg(1)
    Switch $msg[1] ; window-handle
    Case $Form1
    Switch $msg[0] ; event/control-handle
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Pic1

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

    Case $MenuItem2
    Exit
    Case $MenuItem3
    GUISetState(@SW_HIDE, $Form1)
    GUISetState(@SW_SHOW, $Form3)
    Case $Button6
    GUISetState(@SW_HIDE, $Form1)
    GUISetState(@SW_SHOW, $Form2)
    EndSwitch
    Case $Form2
    Switch $msg[0]
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_SHOW, $Form1)
    GUISetState(@SW_HIDE, $Form2)
    EndSwitch
    Case $Form3
    Switch $msg[0]
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_SHOW, $Form1)
    GUISetState(@SW_HIDE, $Form3)
    ;Case $Button2c
    ; _EinstellungSpeichern()
    EndSwitch
    EndSwitch
    WEnd

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


    hmm aber weiter komme ich irgend wie nicht, das prob bei mir ist ich kann mit bugfix seinen script nix anfangen, weil ich nicht verstehe wie so in der func steht Func _blub(sec true und son zeug^^) Ich weiss nicht was rein muss in die func und was raus kommt :pinch:

  • machs doch auf deine eigene art, hab ich auch gemacht! macht viel mehr spaß wenn man dann die erfolge sieht ^^^^

    ich versuche meistens solange herum bis ich es schaffe oder ich hier im forum hilfe brauche =)


    \edit: ich hab das 1. problem jetzt gelöst, mit

    [autoit]

    GUICtrlSetData($sekund, StringFormat("%02d", $s))

    [/autoit]


    aber das 2. problem ist noch offen :D

    kann mir da jemand helfen bitte?

    Einmal editiert, zuletzt von Fisch (22. April 2008 um 23:33)

    • Offizieller Beitrag

    Hi,

    hier mal ein Anfang:

    Spoiler anzeigen
    [autoit]

    ; Stoppuhr

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

    #include<Date.au3>
    Opt('MustDeclareVars', 1)
    HotKeySet('{esc}', '_end')
    HotKeySet('{Pause}', '_stop')

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

    While 1
    ToolTip('Stoppuhr' & @CRLF & '============' & @CRLF & _counter(_NowCalcDate(), '09:10:00') & ' left', _
    @DesktopWidth - 100, 30)
    Sleep(1)
    WEnd

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

    Func _stop()
    While 1
    Sleep(100)
    WEnd
    EndFunc ;==>_stop

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

    Func _counter($s_Date, $s_time)
    Local $returnValue = ''
    If Not _DateIsValid($s_Date & ' ' & $s_time) Then Return -1
    Local $NumberOfSeconds = _DateDiff('s', $s_Date & ' ' & $s_time, _NowCalc())
    Return StringFormat('Days = %.02d' & @CRLF & 'Hours = %.02d' & @CRLF & 'Min = %.02d' & @CRLF & 'Sec = %.02d' & @CRLF & _
    'Msec = %.03d', $NumberOfSeconds / 86400, Mod($NumberOfSeconds / 3600, 24), Mod(($NumberOfSeconds / 60), 60), _
    Mod($NumberOfSeconds, 60), 1000 - _MSec())
    EndFunc ;==>_counter

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

    Func _MSec()
    Local $stSystemTime = DllStructCreate('ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort')
    DllCall('kernel32.dll', 'none', 'GetSystemTime', 'ptr', DllStructGetPtr($stSystemTime))
    Local $sMilliSeconds = StringFormat('%03d', DllStructGetData($stSystemTime, 8))
    $stSystemTime = 0
    Return $sMilliSeconds
    EndFunc ;==>_MSec

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

    Func _end()
    Exit (0)
    EndFunc ;==>_end

    [/autoit]

    Mega

    • Offizieller Beitrag

    Oder etwas anders ;)
    Hier mit 3 Modi:
    - Messung absolut
    - Anzeigestop, weiterlaufende Messung (z.B. Rundenzeiten)
    - unterbrochene Messung
    Momentan für Anzeige mm:ss,zht

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    Global $start, $UsedTime, $diff_Alt = 0
    Global $SetTime = False, $Break = False, $Pause = False, $Run = True

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

    $GUI = GUICreate('Stoppuhr', 400, 100, -1, -1)
    $Time = GUICtrlCreateInput('00:00,000', 100, 20, 200, 20, BitOR($ES_CENTER,$ES_READONLY))
    $bStart = GUICtrlCreateButton('Start', 40, 60, 80, 20)
    $bBreak = GUICtrlCreateButton('Unterbrechen', 160, 60, 80, 20)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $bPause = GUICtrlCreateButton('Pause', 280, 60, 80, 20)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUISetState()

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

    While True
    $msg = GUIGetMsg()
    If $SetTime Then $UsedTime = SetTime()
    Switch $msg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $bStart ; Start/Stop Messung absolut
    $Run = Not $Run
    If $Run Then
    $SetTime = False
    SetTime()
    GUICtrlSetData($bStart, 'Start')
    GUICtrlSetState($bBreak, $GUI_DISABLE)
    GUICtrlSetState($bPause, $GUI_DISABLE)
    Else
    $SetTime = True
    $start = TimerInit()
    GUICtrlSetData($bStart, 'Stop')
    GUICtrlSetState($bBreak, $GUI_ENABLE)
    GUICtrlSetState($bPause, $GUI_ENABLE)
    EndIf
    Case $bBreak ; nur Anzeige wird angehalten (z.B. Rundenmessung)
    $Break = Not $Break
    If $Break Then
    $SetTime = False
    GUICtrlSetData($bBreak, 'Fortsetzen')
    GUICtrlSetState($bPause, $GUI_DISABLE)
    Else
    $SetTime = True
    GUICtrlSetData($bBreak, 'Unterbrechen')
    GUICtrlSetState($bPause, $GUI_ENABLE)
    EndIf
    Case $bPause ; Messung wird angehalten (Additionsmessung)
    $Pause = Not $Pause
    If $Pause Then
    $diff_Alt = $UsedTime ; abgelaufene Zeit aufaddieren
    $SetTime = False
    GUICtrlSetData($bPause, 'Weiter')
    GUICtrlSetState($bBreak, $GUI_DISABLE)
    Else
    $SetTime = True
    $start = TimerInit() ; Zeitmessung neu initialisieren
    GUICtrlSetData($bPause, 'Pause')
    GUICtrlSetState($bBreak, $GUI_ENABLE)
    EndIf
    EndSwitch
    WEnd

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

    Func SetTime()
    Local $diff = TimerDiff($start)/1000 + $diff_Alt
    Local $min = 0
    Local $sec = Floor($diff)
    Local $rest = ($diff-$sec)*1000
    If $sec > 59 Then
    $min = Floor($sec/60)
    $secShow = Mod($sec, 60)
    Else
    $secShow = $sec
    EndIf
    GUICtrlSetData($Time, StringFormat('%02u', $min) & ':' & StringFormat('%02u', $secShow) & ',' & StringFormat('%03u', $rest))
    Return $diff ; gibt abgelaufene Zeit als absolute Differenz zurück
    EndFunc

    [/autoit]