Hey,
ich möchte meinen Router anpingen. Bei einer Antwort soll ein x bei einer Checkbox gesetzt werden. Gibts da irgendeinen Befehl für?
Hey,
ich möchte meinen Router anpingen. Bei einer Antwort soll ein x bei einer Checkbox gesetzt werden. Gibts da irgendeinen Befehl für?
Hallo AUTOIT321,
folgend ein Beispiel, zusammengewürfelt aus der Hilfe.
;~ @error: 1 = Host is offline
;~ 2 = Host is unreachable
;~ 3 = Bad destination
;~ 4 = Other errors
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
$ip = ""
; Create a GUI with various controls.
Local $hGUI = GUICreate("Example", 300, 200)
Local $input = GUICtrlCreateInput("", 10, 10, 100, 20)
Local $ping = GUICtrlCreateButton("Ping", 120, 170, 85, 25)
Local $idCheckbox = GUICtrlCreateCheckbox("Standard Checkbox", 10, 50, 185, 25)
Local $idButton_Close = GUICtrlCreateButton("Close", 210, 170, 85, 25)
; Display the GUI.
GUISetState(@SW_SHOW, $hGUI)
; Loop until the user exits.
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $idButton_Close
ExitLoop
Case $ping
$ip = GUICtrlRead($input)
MsgBox(0,"",$ip)
_ping($ip)
Case $idCheckbox
If _IsChecked($idCheckbox) Then
MsgBox($MB_SYSTEMMODAL, "", "The checkbox is checked.", 0, $hGUI)
Else
MsgBox($MB_SYSTEMMODAL, "", "The checkbox is not checked.", 0, $hGUI)
EndIf
EndSwitch
WEnd
; Delete the previous GUI and all controls.
GUIDelete($hGUI)
Func _IsChecked($idControlID)
Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED
EndFunc ;==>_IsChecked
Func _ping($ip)
; Ping the AutoIt website with a timeout of 250ms.
Local $iPing = Ping($ip, 1000)
If $iPing Then ; If a value greater than 0 was returned then display the following message.
MsgBox(0, "", "The roundtrip-time took: " & $iPing & "ms.")
GUICtrlSetState($idCheckbox, $GUI_CHECKED)
Else
MsgBox(0, "", "An error occurred with @error value of: " & @error)
EndIf
EndFunc
Alles anzeigen
Gruß gmmg