Loop beenden mit Button

  • hallo,
    ich möchte im folgenden beispiel mit den button ok und abbrechen den countdownloop beenden. das ganze würde auch funktionieren, wenn da nicht das fenster FormOptions währe.
    woran kann das liegen? muss ich ein fenster irgendwie noch aktivieren, deaktivieren, switchen, ...???
    kann mir jemand einen tipp geben.

    [autoit]

    #include <GUIConstants.au3>

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

    Opt("GUIOnEventMode", 1)

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

    Global $LblTxt, $BtnOK

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

    $FormOptions = GUICreate("Optionen", 640, 480, -1, -1, BitOr($WS_POPUP,$WS_DLGFRAME, $DS_SETFOREGROUND))
    $Btn1 = GUICtrlCreateButton("test", 80, 55, 75, 25, 0)
    GUICtrlSetOnEvent(-1, "_Start")
    GUISetState(@SW_SHOW, $FormOptions)

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

    While 1
    Sleep(5)
    WEnd

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

    Func _MsgBox($MsgTitle, $MsgBtn1, $MsgBtn2, $MsgIconFile, $MsgIconNo, $MsgText)
    $FormCountDownMsG = GUICreate($MsgTitle, 300, 110, -1, -1, $WS_DLGFRAME)
    $BtnOK = GUICtrlCreateButton($MsgBtn1, 80, 55, 75, 25, 0)
    GUICtrlSetOnEvent(-1, "_MsgBtnOK")
    $BtnCancel = GUICtrlCreateButton($MsgBtn2, 190, 55, 75, 25, 0)
    GUICtrlSetOnEvent(-1, "_Exit")
    $Icon = GUICtrlCreateIcon($MsgIconFile, $MsgIconNo, 16, 16, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP))
    $LblTxt = GUICtrlCreateLabel($MsgText, 72, 16, 210, 25)
    GUISetState(@SW_SHOW, $FormCountDownMsG)
    EndFunc

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

    Func _MsgBtnOK()
    MsgBox(16,"Shutdown","Shutdown 2")
    EndFunc

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

    Func _Exit()
    Exit
    EndFunc

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

    Func _MsgBoxCountDown()
    For $i = 10 To 1 Step -1
    GUICtrlSetData($LblTxt, "Computer will restart in "&$i&" seconds.")
    GUICtrlSetData ($BtnOK, "OK ( "&$i&" )" )
    sleep(1000)
    If $i = 1 Then
    Return -1
    EndIf
    Next
    EndFunc

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

    Func _Start()
    GUISetState(@SW_HIDE, $FormOptions)
    _MsgBox("Information", "OK", "Cancel", "Shell32.dll", 221, "")
    $MsgCounterEnd = _MsgBoxCountDown()
    If $MsgCounterEnd = -1 Then
    MsgBox(16,"Shutdown","Shutdown 2")
    Exit
    EndIf
    EndFunc

    [/autoit]
  • hab jetzt die lösung gefunden, AdlibEnable("_MsgBoxCountDown"). bleibt noch die frage wo setze ich am besten AdlibDisable().


    [autoit]

    Func _Start()
    GUISetState(@SW_HIDE, $FormOptions)
    _MsgBox("Information", "OK", "Cancel", "Shell32.dll", 221, "")
    $MsgCounterEnd = AdlibEnable("_MsgBoxCountDown")
    If $MsgCounterEnd = -1 Then
    MsgBox(16,"Shutdown","Shutdown 2")
    ;Exit
    EndIf
    EndFunc

    [/autoit]