aus einer Do...Until Schleife heraus neben ESC als Abbruch Event den Abbruch mit $Gui_Event_Close herbeiführen

  • Hi all,
    irgendwie stehe ich seit gestrn auf dem Schlauch. Mir gelingt es einfach nicht aus einer Do...Until Schleife heraus neben ESC als Abbruch Event den Abbruch mit $Gui_Event_Close herbeiführen ....

    M.E. liegt das daran, dass ich den $GUI_EVENT_CLOSE innerhalb der Schleife herbeiführen muss. Und genau das klappt nicht

    ?(

    Vielleicht ist das ja ganz einfach - wenn man es weiss - Danke schon einmal im voraus für jedwede Hilfe


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

    $bStop = False
    HotKeySet('{ESC}', '_Stop')
    Do
    $iDiff = _DateDiff('s', '2010/08/15 08:00:00', _NowCalc())
    GUICtrlSetData($Timer, _SecondsToDateTime($iDiff))
    Sleep(500)
    Until $bStop
    Exit

    WEnd


    Func _Stop()
    $bStop = True
    EndFunc ;==>_Stop


    Gruss
    Chris

    Einmal editiert, zuletzt von ugt100 (6. November 2009 um 13:57)

  • solange in du in der do-until schleife bist frägt er nicht ab ob $GUI_EVENT_CLOSE gedrückt wird.

    das wäre eine lösung aber sicher nicht die beste, kommt auf den restlichen teil deines scriptes an...

    [autoit]

    HotKeySet('{ESC}', '_Stop')

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    $iDiff = _DateDiff('s', '2010/08/15 08:00:00', _NowCalc())
    GUICtrlSetData($Timer, _SecondsToDateTime($iDiff))
    Sleep(500)
    WEnd

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

    Func _Stop()
    Exit
    EndFunc ;==>_Stop

    [/autoit]
  • Hi Schnitzel,


    ja genau das ist die Sache. Mit der u.a.abgeänderten Variante funzt das zwar, aber das $GUI_EVENT_CLOSE reagiert ziemlich zeitversetzt.

    Mal schauen vielleicht gibt es ja noch andere Möglichkeiten

    $bStop = False
    HotKeySet('{ESC}', '_Stop')

    Do
    $nMsg = GUIGetMsg()
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then
    Exit
    EndIf
    $iDiff = _DateDiff('s', '2010/08/15 08:00:00', _NowCalc())
    GUICtrlSetData($Timer, _SecondsToDateTime($iDiff))
    Sleep(500)

    Until $bStop

    Func _Stop()
    $bStop = True
    EndFunc ;==>_Stop

  • Hilft das vielleicht? Keine Zeitversetzung, und dürfte auch mit ner Do-Until Schleife funktionieren.


    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

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

    HotKeySet("{esc}","_ende")

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

    $go=False

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

    Run("notepad.exe")

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

    $MainGUI = GUICreate("MainGUI", 258, 108, Default, Default)
    $Start = GUICtrlCreateButton("Start", 24, 40, 89, 33, $WS_GROUP)
    $Stop = GUICtrlCreateButton("Stop", 136, 40, 89, 33, $WS_GROUP)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Start
    $go=True
    $timer=TimerInit()
    While $go * sleep(10)
    If GUIGetMsg() = $Stop Then $go=False
    If TimerDiff($timer) > 200 Then
    ControlSend("Unbenannt - Editor","","[CLASS:Edit; INSTANCE:1]","test"&@CRLF)
    $timer=TimerInit()
    EndIf
    WEnd
    Case $Stop
    $go=False

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

    EndSwitch
    WEnd

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

    Func _ende()
    Exit
    EndFunc

    [/autoit]


    Hier die While schleife nochmal als Do-Until ;)

    Spoiler anzeigen
    [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Start
    $go=True
    $timer=TimerInit()
    Do
    sleep(10)
    If GUIGetMsg() = $Stop Then $go = False
    If TimerDiff($timer) > 200 Then
    ControlSend("Unbenannt - Editor","","[CLASS:Edit; INSTANCE:1]","test"&@CRLF)
    $timer=TimerInit()
    EndIf
    Until $go = False ; OR _IsPressed(18) OR ...
    Case $Stop
    $go=False

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

    EndSwitch
    WEnd

    [/autoit]