Du Loggst ja auch nur die Pingzeiten
Spoiler anzeigen
#comments-start-----------------------------------------------------------------------------------------------------------
; Author: Raylow (Special thx to "funkey" --> http://www.autoit.de)
; Date: 23.04.2009
; Script Version: 2.1.0.1
;
;
#comments-end-----------------------------------------------------------------------------------------------------------
#NoTrayIcon
#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=Netzwerkverbindung.ico
#AutoIt3Wrapper_Res_Description=Application to ping a host periodically
#AutoIt3Wrapper_Res_Fileversion=2.1.0.1
#AutoIt3Wrapper_Res_Icon_Add=paste.ico
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <File.au3>
#include <windowsconstants.au3>
Global $ping = -1, $pingCopy = -2
Global $intervall = "60000"
Global $date = @YEAR & "-" & @MON & "-" & @MDAY
Global $stopped = 0
Global $path = ""
$StartFolder = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]$Form1_1 = GUICreate("Ping-Assi", 247, 145, 240, 300)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1_1Close")
GUISetState(@SW_SHOW)
$Label1 = GUICtrlCreateLabel("Host to ping", 8, 8, 80, 17)
$Label2 = GUICtrlCreateLabel("Intervall", 160, 8, 38, 17)
$Label3 = GUICtrlCreateLabel("Logfile Path", 8, 58, 98, 17)
Global $Input1 = GUICtrlCreateInput("", 8, 24, 105, 21)
ControlFocus($Form1_1, "", $Input1)
Global $Input2 = GUICtrlCreateInput($intervall, 160, 24, 32, 21)
Global $Input3 = GUICtrlCreateInput("", 8, 74, 194, 21)
Global $Button1 = GUICtrlCreateButton("Start", 8, 104, 114, 30, $BS_DEFPUSHBUTTON)
GUICtrlSetOnEvent(-1, "Button1Click")
Global $Button2 = GUICtrlCreateButton("Stop", 126, 104, 114, 30)
GUICtrlSetOnEvent(-1, "Button2Click")
GUICtrlSetState($Button2, $GUI_DISABLE)
Global $Button3 = GUICtrlCreateButton("...", 205, 74, 35, 21)
GUICtrlSetOnEvent(-1, "Button3Click")
Global $Button4 = GUICtrlCreateButton("Clip", 115, 24, 35, 21, $BS_ICON)
GUICtrlSetImage($Button4, @ScriptFullPath, -5, 0)
GUICtrlSetOnEvent(-1, "Button4Click")
Global $Button5 = GUICtrlCreateButton("?", 225, 8, 15, 17)
GUICtrlSetOnEvent(-1, "Button5Click")
While 1
Sleep(5000)
WEnd
Func Button5Click()
MsgBox(64, "About Ping-Assi", "This programm was written by Raylow ([email='raylow.com@gmail.com'][/email]). Special thx to funkey --> http://www.autoit.de")
ControlFocus($Form1_1, "", $Input1)
EndFunc ;==>Button5Click
Func Button4Click()
GUICtrlSetData($Input1, ClipGet())
EndFunc ;==>Button4Click
Func Button3Click()
Dim $fileName
If GUICtrlRead($Input1) = "" Then
$var = FileSaveDialog("Save logfile..", $StartFolder, "Logfile (*.*)", 16, "log.txt")
Else
$var = FileSaveDialog("Save logfile..", $StartFolder, "Logfile (*.*)", 16, StringReplace(GUICtrlRead($Input1), ".", "_") & ".txt")
EndIf
If @error Then
[/autoit] [autoit][/autoit] [autoit]Else
GUICtrlSetData($Input3, $var)
EndIf
EndFunc ;==>Button3Click
Func Button1Click()
If GUICtrlRead($Input1) <> "" Then
Global $IP = StringReplace(GUICtrlRead($Input1), ".", "_")
If GUICtrlRead($Input3) = "" Then
Global $logfile = $IP & ".txt"
Else
Global $logfile = GUICtrlRead($Input3)
EndIf
Local $IPAdresse = GUICtrlRead($Input1)
$ping = Ping($IPAdresse, 1800)
_FileWriteLog($logfile, '----- ' & 'STARTED' & ' -----')
_FileWriteLog($logfile, $IPAdresse & ' | ' & $ping)
$pingCopy = $ping
AdlibRegister('_Zyklus', GUICtrlRead($Input2 * 1000))
GUICtrlSetState($Button1, $GUI_DISABLE)
GUICtrlSetState($Button2, $GUI_ENABLE)
GUICtrlSetState($Button3, $GUI_DISABLE)
GUICtrlSetState($Button4, $GUI_DISABLE)
GUICtrlSetState($Input1, $GUI_DISABLE)
GUICtrlSetState($Input2, $GUI_DISABLE)
GUICtrlSetState($Input3, $GUI_DISABLE)
Else
MsgBox(16, "Missing Input", "Be sure to set the host to ping and an intervall!")
EndIf
EndFunc ;==>Button1Click
Func Button2Click()
_FileWriteLog($logfile, '----- ' & 'STOPPED' & ' -----')
$stopped = 2
AdlibUnRegister()
GUICtrlSetState($Button1, $GUI_ENABLE)
GUICtrlSetState($Button2, $GUI_DISABLE)
GUICtrlSetState($Button3, $GUI_ENABLE)
GUICtrlSetState($Button4, $GUI_ENABLE)
GUICtrlSetState($Input1, $GUI_ENABLE)
GUICtrlSetState($Input2, $GUI_ENABLE)
GUICtrlSetState($Input3, $GUI_ENABLE)
EndFunc ;==>Button2Click
Func _Zyklus()
Local $IPAdresse = GUICtrlRead($Input1)
$ping = Ping($IPAdresse)
$stopped = 1
;~ If $ping <> $pingCopy Then _FileWriteLog($logfile, $IPAdresse & ' | ' & $ping)
If $ping = 0 Then _FileWriteLog($logfile, $IPAdresse & ' | Host nicht erreichbar')
$pingCopy = $ping
EndFunc ;==>_Zyklus
Func Form1_1Close()
If $stopped = 1 Then
_FileWriteLog($logfile, '----- ' & 'STOPPED' & ' -----')
Else
EndIf
[/autoit] [autoit][/autoit] [autoit]Exit
EndFunc ;==>Form1_1Close
Damit sollte es klappen