Schleife beenden

  • Hallo,
    Hab mir da ein kleines Skript (bin Anfänger) zum Pingen geschrieben.
    Geht auch soweit! bis auf die Kleinigkeit, das ich nicht mehr aus der schleife
    raus komme.
    Kann mir da vielleicht jemand helfen?

    Spoiler anzeigen
    [autoit]

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

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

    Opt("GUIOnEventMode", 1)

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

    GUICreate("Ping", 206, 170, -1, -1)
    $Button1 = GUICtrlCreateButton("OK", 13, 114, 83, 33, $WS_GROUP)
    GUICtrlSetFont(-1, 10, 400, 0, "Segoe UI")
    $Button2 = GUICtrlCreateButton("Abbrechen", 109, 114, 83, 33, $WS_GROUP)
    GUICtrlSetFont(-1, 10, 400, 0, "Segoe UI")
    $Input1 = GUICtrlCreateInput("192.168.178.14", 40, 64, 129, 25, $SS_CENTER)
    GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI")
    GUICtrlCreateLabel("IP oder DNS-Name Eingeben!", 13, 24, 178, 21)
    GUICtrlSetFont(-1, 10, 400, 0, "Segoe UI")
    GUISetState(@SW_SHOW)

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

    GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
    GUICtrlSetOnEvent($Button2, "Button2Click")
    GUICtrlSetOnEvent($Button1, "Button1Click")

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

    $value = GUICtrlRead($Input1)

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

    While 1
    Sleep(100)
    WEnd

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

    Func Form1Close()
    Exit
    EndFunc

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

    Func Button2Click()
    Exit
    EndFunc

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

    Func Button1Click()

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

    While 1
    Sleep(1000)
    Ping($value)
    ;MsgBox(0,"Test",$value)
    WEnd

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

    EndFunc

    [/autoit]

    Einmal editiert, zuletzt von Dietus (5. August 2010 um 10:06)

  • Hatte Ich schon versucht !

    hat aber irgendwie nicht funktioniert

    [autoit]

    Func Button2Click()
    ExitLoop
    EndFunc

    [/autoit]
  • [autoit]

    Exitloop;funktioniert nur bei einer Schleife zb while wend
    Return;musst du nehmen um aus ner funktion raus zu kommen

    [/autoit]
  • Hallo Dietus,

    wenn du es so machst klappt es:

    Spoiler anzeigen
    [autoit]

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

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

    Opt("GUIOnEventMode", 1)

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

    GUICreate("Ping", 206, 170, -1, -1)
    $Button1 = GUICtrlCreateButton("OK", 13, 114, 83, 33, $WS_GROUP)
    GUICtrlSetFont(-1, 10, 400, 0, "Segoe UI")
    $Button2 = GUICtrlCreateButton("Abbrechen", 109, 114, 83, 33, $WS_GROUP)
    GUICtrlSetFont(-1, 10, 400, 0, "Segoe UI")
    $Input1 = GUICtrlCreateInput("192.168.178.14", 40, 64, 129, 25, $SS_CENTER)
    GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI")
    GUICtrlCreateLabel("IP oder DNS-Name Eingeben!", 13, 24, 178, 21)
    GUICtrlSetFont(-1, 10, 400, 0, "Segoe UI")
    GUISetState(@SW_SHOW)

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

    GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
    GUICtrlSetOnEvent($Button2, "Button2Click")
    GUICtrlSetOnEvent($Button1, "Button1Click")

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

    $value = GUICtrlRead($Input1)

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

    While 1
    Sleep(100)
    WEnd

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

    Func Form1Close()
    Exit
    EndFunc ;==>Form1Close

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

    Func Button2Click()
    AdlibUnRegister("PingIt")
    EndFunc ;==>Button2Click

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

    Func Button1Click()
    AdlibRegister("PingIt", 1000)
    EndFunc ;==>Button1Click

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

    Func PingIt()
    While 1
    Sleep(1000)
    Ping($value)
    ;MsgBox(0,"Test",$value)
    WEnd
    EndFunc ;==>PingIt

    [/autoit]

    viel Spass damit

    mfg (Auto)Bert