while schleifen problem !

  • hi so da mir aufgefallen ist das nie so richtig weis wie ich die while schleife einfach bende oder stope werd ich jetz hir ma fragen : wie bende/stoppe ich eine while schleife ir ein beispiel wie ich es ma versucht hab naja rumgespield :D

    Spoiler anzeigen
    [autoit]


    ***************************------>>>>>
    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 116, 95, 192, 124)
    $Button1 = GUICtrlCreateButton("Button1", 16, 16, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Button2", 16, 48, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    $set = stop()

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    case $Button1
    start()
    case $Button2
    stop ()
    EndSwitch
    WEnd

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

    Func start()
    While 2
    send("hello")
    if $set then ExitLoop

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

    WEnd
    EndFunc

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

    Func stop()

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

    Exit
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit]
  • Case $Button2
    ExitLoop

    So sollte es gehen, wenn du es immernoch nicht weist dann guck mal in der Hilfe bei ExitLoop

  • hmmmm :pinch: :huh:
    hast du das ma mit dem skrpt versucht das ich gepostet hab ? funzt nemlich nich !
    und inder hilfe hab ich schon geckukt :D

  • Bedingung in der While Schleife angeben, ist Kopf gesteuert im gegensatz zu Do ... Until.

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 116, 95, 192, 124)
    $Button1 = GUICtrlCreateButton("Button1", 16, 16, 75, 25, $WS_GROUP)
    ;~ $Button2 = GUICtrlCreateButton("Button2", 16, 48, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    Global $set = 1

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

    HotKeySet ( "!e", "stop" )

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    start()
    ;~ Case $Button2
    ;~ stop ()
    EndSwitch
    WEnd

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

    Func start()
    $set = 1
    Run("notepad.exe")
    WinWaitActive ( "Unbenannt - Editor" )
    WinActivate ( "Unbenannt - Editor" )
    While $set=1
    Send("hello")
    Sleep ( 300 )
    WEnd
    EndFunc

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

    Func stop()
    $set=0
    EndFunc

    [/autoit]

    Edit: Über die GUI kannst du es nicht beenden, da die nicht mehr abgefragt wird. ( Außer du tust sie mit AdlibEnable immer abfragen, aber das Funktioniert nicht ganz perfekt. )

  • also kan man keine while scheife mit buttons stoppen/beenden !

    Doch, les das Edit, hier ein Beispiel:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 116, 95, 192, 124)
    $Button1 = GUICtrlCreateButton("Button1", 16, 16, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Button2", 16, 48, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    Global $set = 1

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

    AdlibEnable ( "_check", 120 )

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    start()
    Case $Button2
    stop ()
    EndSwitch
    WEnd

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

    Func start()
    $set = 1
    Run("notepad.exe")
    WinWaitActive ( "Unbenannt - Editor" )
    WinActivate ( "Unbenannt - Editor" )
    While $set=1
    Send("hello")
    Sleep ( 300 )
    WEnd
    EndFunc

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

    Func stop()
    $set=0
    EndFunc

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

    Func _check()
    $nMsg=GUIGetMsg()
    If $nMsg=$Button2 Then $set=0
    EndFunc

    [/autoit]

    Aber wie gesagt, das ist nicht zu 100% zuverlässig.

  • stimmt funzt erst beim 2 klick :|
    naja immerhin etwas was zum teil funzt :D
    aber schon ma ein Fettes THX an den guten Greek ;)