Hilfe

  • hi ich versuche mit _Timer_SetTimer ne überprüfung laufen zu lassen die mir nen timer stopt nun hängt sich aber mein programm auf
    bitte um hilfe

    [autoit]

    #include <ComboConstants.au3>
    #include <GUIComboBox.au3>
    #include <Constants.au3>
    #include <ComboConstants.au3>
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <GUIConstants.au3>
    #include <DateTimeConstants.au3>
    #include <Array.au3>
    #include <Date.au3>
    #include <String.au3>
    #include <INet.au3>
    #include <IE.au3>
    #include <GuiIPAddress.au3>
    #include <GuiListView.au3>
    #include <GUIListBox.au3>
    #include <GuiTreeView.au3>
    #include <file.au3>
    #include <ListBoxConstants.au3>
    #include <ListViewConstants.au3>
    #include <Timers.au3>
    #include <GuiStatusBar.au3>
    #include "GUIScroll.au3"
    #include <DateTimeConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

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

    Global $aParts[4] = [70, 194, 990 - 110]
    Global $hIcons[2]
    Global $Sec, $Min, $Hour, $Time, $Button_planer, $Button_planer_stop, $lasda, $n
    Global $t1
    $hIcons[0] = _WinAPI_LoadShell32Icon(27)
    $hIcons[1] = _WinAPI_LoadShell32Icon(13)
    $Haupt_Fenster = GUICreate("Blabla", 990, 798, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_BORDER, $WS_CLIPSIBLINGS))
    $Haupt_Tab = GUICtrlCreateTab(0, 0, 988, 796)
    $Browser_Tab = GUICtrlCreateTabItem("Browser")
    $Button_planer = GUICtrlCreateButton("Speichern", 428, 190, 75, 20)
    $Button_planer_stop = GUICtrlCreateButton("Stopen", 428, 215, 75, 20)
    $hStatusBar = _GUICtrlStatusBar_Create($Haupt_Fenster, $aParts)
    _GUICtrlStatusBar_SetText($hStatusBar, @TAB & @TAB & @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC, 3)
    _GUICtrlStatusBar_SetText($hStatusBar, "Offline", 0)
    _GUICtrlStatusBar_SetIcon($hStatusBar, 0, $hIcons[0])
    _Timer_SetTimer($Haupt_Fenster, 1000, "_UpdateStatusBarClock") ; create timer
    _Timer_SetTimer($Haupt_Fenster, 2500, "_timeraus") ; create timer
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button_planer_stop
    _Timer_KillTimer($Haupt_Fenster, $lasda)
    Case $Button_planer
    $lasda = _Timer_SetTimer($Haupt_Fenster, 1000, "_timer_start") ; create timer
    EndSwitch
    WEnd

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

    Func _UpdateStatusBarClock($hWnd, $Msg, $iIDTimer, $dwTime)
    _GUICtrlStatusBar_SetText($hStatusBar, @TAB & @TAB & @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC, 3)
    EndFunc ;==>_UpdateStatusBarClock

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

    Func _timer_start($hWnd, $Msg, $iIDTimer, $dwTime)
    $t1 = "2012/06/07 18:43:00"
    ;~ $t1 = GUICtrlRead($n)
    $t2 = _NowCalc()
    $diff = _DateDiff('s', $t2, $t1)
    Select
    Case $diff < 60
    $sDiff = StringFormat('%02u', $diff) & ' s'
    Case $diff < 60 * 60
    $sDiff = StringFormat('%02u', Floor($diff / 60)) & ':' & _
    StringFormat('%02u', Mod($diff, 60)) & ' min'
    Case $diff < 60 * 60 * 24
    $sDiff = StringFormat('%02u', Floor($diff / 3600)) & ':' & _
    StringFormat('%02u', Floor(Mod($diff, 3600) / 60)) & ':' & _
    StringFormat('%02u', Mod(Mod($diff, 3600), 60)) & ' h'
    Case Else
    $sDiff = Floor($diff / 86400) & ' d / ' & _
    StringFormat('%02u', Floor(Mod($diff, 86400) / 3600)) & ':' & _
    StringFormat('%02u', Floor(Mod(Mod($diff, 86400), 3600) / 60)) & ':' & _
    StringFormat('%02u', Mod(Mod(Mod($diff, 86400), 3600), 60)) & ' h'
    EndSelect
    If $diff = 0 Then
    _GUICtrlStatusBar_SetText($hStatusBar, "Timer abgelaufen", 2)
    ;~ _timeraus()
    Else
    _GUICtrlStatusBar_SetText($hStatusBar, $sDiff, 2)
    EndIf
    EndFunc ;==>_UpdateStatusBarClock_test

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

    Func _timeraus($hWnd, $Msg, $iIDTimer, $dwTime)
    ;~ Func _timeraus()
    If _GUICtrlStatusBar_GetText($hStatusBar, 2) = "Timer abgelaufen" Then
    _Timer_KillTimer($Haupt_Fenster, $lasda)
    _GUICtrlStatusBar_SetText($hStatusBar, "", 2)
    EndIf
    EndFunc ;==>_timeraus

    [/autoit]

    $t1 = "2012/06/07 18:43:00"
    mus natürlich angepasst werden das es in der zukunft liegt

    2 Mal editiert, zuletzt von Lusche (7. Juni 2012 um 18:50)

  • naja finds auch nicht raus an was das liegt, aber die funktion kannst dir doch eigentlich auch sparen, und den timer killen in dem "if $diff=0 Then", da weißt du ja schon das der timer weg muss

    Ich denke mir das es imme rzufällig crasht, wenn 2 timer gleichtzeitg getrigerred werden, aber kp

    €dit: jetzt bleibt er grad gat nicht mehr hängen, obwohl ich wieders originale skript von dir hab, sehr seltsam, manchmal hab ich auch eine meldung bekommen _SendMessage(...,..) weiß´parameter grad nicht mehr ( $parameter used without being declared)

    Einmal editiert, zuletzt von Death (7. Juni 2012 um 21:19)