ich an deiner stelle würds so machen:
Spoiler anzeigen
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <WindowsConstants.au3>
GUICreate("", 245, 400)
$addressInput = GUICtrlCreateInput("", 15, 25, 215, 20)
$slider = GUICtrlCreateSlider(15, 85, 215, 20)
GUICtrlSetLimit($slider, 10)
GUICtrlSetData($slider, 5)
GUICtrlCreateLabel("- 1 2 3 4 5 6 7 8 9 10", 20, 108)
$startButton = GUICtrlCreateButton("ping", 16, 158, 100, 25)
$stopButton = GUICtrlCreateButton("stop", 129, 158, 100, 25)
$resultsEdit = GUICtrlCreateEdit("", 15, 225, 220, 130, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL,$ES_READONLY))
GUICtrlSetBkColor($resultsEdit,0xffffff)
GuiSetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $startButton
$interval = GUICtrlRead($slider)
If ($interval > 0) Then
AdlibRegister("start", $interval * 1000) ; Adlibregister macht dass die funktion alle x sekunden aufgerufen wird
Else
start()
EndIf
Case $msg = $stopButton
AdlibUnRegister("start") ; stellt Adlibregister ab --> die funktion wird nicht mehr alle x sekunden ausgeführt
Case $msg = $GUI_EVENT_CLOSE
Exit
EndSelect
WEnd
Func start()
$address = GUICtrlRead($addressInput)
$ping = Ping($address, 250)
If Not @error Then
_GUICtrlEdit_AppendText($resultsEdit, $ping & "ms" & @CRLF)
Else
_GUICtrlEdit_AppendText($resultsEdit, "Error" & @CRLF)
AdlibUnRegister("start") ; stellt Adlibregister ab --> die funktion wird nicht mehr alle x sekunden ausgeführt
EndIf
EndFunc