Endlosschleife abbrechen ?

  • Hallo

    Ich habe mal ne Frage unzwar ,wie kann ich eine

    While 1
    ..

    WEnd

    Schleife beenden


    hier ma das skript:

    [autoit]

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

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("The Way to AfK", 283, 83, 192, 124, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
    $Label1 = GUICtrlCreateLabel("Client:", 8, 8, 40, 17)
    $Combo1 = GUICtrlCreateCombo("", 48, 8, 145, 25)
    $Label2 = GUICtrlCreateLabel("", 8, 48, 4, 4)
    $Radio1 = GUICtrlCreateRadio("Person 1", 208, 8, 73, 17)
    $Button1 = GUICtrlCreateButton("Start", 64, 48, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Stop", 176, 48, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    If GUICtrlRead($Radio1) = $Gui_CHECKED Then
    While 1

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

    ControlSend(GUICtrlRead($Combo1), "", "Edit1", "1")
    Sleep(10000)
    WEnd
    Else
    MsgBox(48, "", "Take a tick into the Radiobox!")
    EndIf
    Case $Button2
    ExitLoop
    hier weiss ich jetzt net ...

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

    EndSwitch
    WEnd

    [/autoit]
  • beschreib mal genauer was du willst. du beendest ja die schleife mit deinem stop button.

    wenn du willst dass er dannach noch weitermacht musst du den code einfach unter die schleife schreiben:

    [autoit]

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

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("The Way to AfK", 283, 83, 192, 124, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
    $Label1 = GUICtrlCreateLabel("Client:", 8, 8, 40, 17)
    $Combo1 = GUICtrlCreateCombo("", 48, 8, 145, 25)
    $Label2 = GUICtrlCreateLabel("", 8, 48, 4, 4)
    $Radio1 = GUICtrlCreateRadio("Person 1", 208, 8, 73, 17)
    $Button1 = GUICtrlCreateButton("Start", 64, 48, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Stop", 176, 48, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    If GUICtrlRead($Radio1) = $Gui_CHECKED Then
    While 1

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

    ControlSend(GUICtrlRead($Combo1), "", "Edit1", "1")
    Sleep(10000)
    WEnd
    Else
    MsgBox(48, "", "Take a tick into the Radiobox!")
    EndIf
    Case $Button2
    ExitLoop

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

    EndSwitch
    WEnd

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

    msgbox(0,"","Hier gehts weiter")

    [/autoit]
  • Schleifen mit einem Button beenden funktioniert nie so richtig...

    Mit Timern kannst du es so machen:

    Spoiler anzeigen
    [autoit]

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

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

    Global $go = True

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("The Way to AfK", 283, 83, 192, 124, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
    $Label1 = GUICtrlCreateLabel("Client:", 8, 8, 40, 17)
    $Combo1 = GUICtrlCreateCombo("", 48, 8, 145, 25)
    $Label2 = GUICtrlCreateLabel("", 8, 48, 4, 4)
    $Radio1 = GUICtrlCreateRadio("Person 1", 208, 8, 73, 17)
    $Button1 = GUICtrlCreateButton("Start", 64, 48, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Beenden", 176, 48, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    If GUICtrlRead($Radio1) = $Gui_CHECKED Then
    GUICtrlSetData($Button2,"Stop")
    $go=True
    $timer=TimerInit()
    While $go * sleep(10)
    If GUIGetMsg() = $Button2 Then
    $go=False
    GUICtrlSetData($Button2,"Beenden")
    EndIf
    If TimerDiff($timer) > 10000 Then
    ControlSend(GUICtrlRead($Combo1), "", "Edit1", "1")
    $timer=TimerInit()
    EndIf
    WEnd
    Else
    MsgBox(48, "", "Take a tick into the Radiobox!")
    EndIf
    Case $Button2
    ExitLoop
    EndSwitch
    WEnd

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

    msgbox(0,"","Hier gehts weiter")

    [/autoit]

    Oder AdlibEnable, aber das dann hängt das GUI, ist alles nicht so das perfekt, was besseres hab ich dazu noch nicht gefunden.

  • Greek hat eigentlich schon alles gesagt. Allerdings würde ich

    [autoit]

    If GUIGetMsg() = $Button2 Then

    [/autoit]


    hier noch eine Hilfsvariable einsetzen.Ich hab die Erfahrung gemacht, dass man sonst ggf mehrmals auf den Stop Button drücken muss. also einfach

    [autoit]

    $nMsg2 = GUIGetMsg()
    If $nMsg2 = $Button2 Then

    [/autoit]