Hallo, ich habe ein kleines Programm geschrieben, wo ich einen Server anfragen kann.
Nun würde ich gerne noch den Timer anzeigen lassen, weiss aber nicht wie ich das anstellen soll...
Das Programm macht schon soweit was es soll, aber falls einer einen Verbesserungsvorschlag hat, ist das gerne gesehen.
Vielen dank schon einmal.
Server Status.au3
C
#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <ColorConstants.au3>
#include <Date.au3>
#include <StaticConstants.au3>
Local $hDLL = DllOpen("user32.dll")
$config_serverip = IniRead (@ScriptDir & "\config.ini", "server", "serverip", 1)
$config_server1 = IniRead (@ScriptDir & "\config.ini", "server", "server1", 1)
$config_server1port = IniRead (@ScriptDir & "\config.ini", "server", "server1port", 1)
$config_server2 = IniRead (@ScriptDir & "\config.ini", "server", "server2", 1)
$config_server2port = IniRead (@ScriptDir & "\config.ini", "server", "server2port", 1)
$config_server3 = IniRead (@ScriptDir & "\config.ini", "server", "server3", 1)
$config_server3port = IniRead (@ScriptDir & "\config.ini", "server", "server3port", 1)
$config_timer = IniRead (@ScriptDir & "\config.ini", "server", "timer", 1)
$config_server_text0 = IniRead (@ScriptDir & "\config.ini", "server", "text0", 1)
$config_server_text1 = IniRead (@ScriptDir & "\config.ini", "server", "text1", 1)
$config_server_text2 = IniRead (@ScriptDir & "\config.ini", "server", "text2", 1)
$Form1 = GUICreate($config_server_text0, 100, 220)
$Title1 = GUICtrlCreateLabel($config_server_text1, 0, 4, 100, 42, $SS_CENTER)
$Title2 = GUICtrlCreateLabel($config_server_text2, 0, 20, 100, 42, $SS_CENTER)
$Server1 = GUICtrlCreateLabel("", 5, 40, 12, 12)
GUICtrlSetBkColor($Server1, 0xaaaaaa)
$Button1 = GUICtrlCreateLabel($config_server1, 22 , 40, 90, 20)
$Server2 = GUICtrlCreateLabel("", 5, 60, 12, 12)
GUICtrlSetBkColor($Server2, 0xaaaaaa)
$Button2 = GUICtrlCreateLabel($config_server2, 22 , 60, 90, 20)
$Server3 = GUICtrlCreateLabel("", 5, 80, 12, 12)
GUICtrlSetBkColor($Server3, 0xaaaaaa)
$Button3 = GUICtrlCreateLabel($config_server3, 22 , 80, 90, 20)
$Output1 = GUICtrlCreateLabel("", 5, 100, 90, 32)
GUICtrlSetBkColor($Output1, 0xdddddd)
$Output2 = GUICtrlCreateLabel("", 5, 135, 90, 32)
GUICtrlSetBkColor($Output2, 0xdddddd)
$Output3 = GUICtrlCreateLabel("", 5, 170, 90, 32)
GUICtrlSetBkColor($Output3, 0xdddddd)
$Timer = GUICtrlCreateLabel("Timer", 0, 204, 100, 72, $SS_CENTER)
GUISetOnEvent($GUI_EVENT_CLOSE, "ExitApp")
GUISetState(@SW_SHOW)
TCPStartup()
$time=TimerInit()
HotKeySet("!e", "_end")
#include <Timers.au3>
$timer = TimerInit()
_FirstCheck()
While 1
$msg = GUIGetMsg()
If Int(TimerDiff($timer)/ 1000) >= $config_timer Then
_ServerCheck()
$timer = TimerInit()
EndIf
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd
Func _FirstCheck()
$socket1 = TCPConnect($config_serverip, $config_server1port)
If $socket1 = -1 Then
GuiCtrlSetData($Output1, $config_server1 & " is down " &@CRLF& _DateTimeFormat(_NowCalc(), 2) &" - "& _DateTimeFormat(_NowCalc(), 4))
GUICtrlSetBkColor($Server1, 0xff0000)
GUICtrlSetBkColor($Output1, 0xff0000)
else
GuiCtrlSetData($Output1, $config_server1 & " is ok " &@CRLF& _DateTimeFormat(_NowCalc(), 2) &" - "& _DateTimeFormat(_NowCalc(), 4))
GUICtrlSetBkColor($Server1, 0x8fff89)
GUICtrlSetBkColor($Output1, 0xdddddd)
EndIf
$socket2 = TCPConnect($config_serverip, $config_server2port)
If $socket2 = -1 Then
GuiCtrlSetData($Output2, $config_server2 & " is down " &@CRLF& _DateTimeFormat(_NowCalc(), 2) &" - "& _DateTimeFormat(_NowCalc(), 4))
GUICtrlSetBkColor($Server2, 0xff0000)
GUICtrlSetBkColor($Output2, 0xff0000)
else
GuiCtrlSetData($Output2, $config_server2 & " is ok " &@CRLF& _DateTimeFormat(_NowCalc(), 2) &" - "& _DateTimeFormat(_NowCalc(), 4))
GUICtrlSetBkColor($Server2, 0x8fff89)
GUICtrlSetBkColor($Output2, 0xdddddd)
EndIf
$socket3 = TCPConnect($config_serverip, $config_server3port)
If $socket3 = -1 Then
GuiCtrlSetData($Output3, $config_server3 & " is down " &@CRLF& _DateTimeFormat(_NowCalc(), 2) &" - "& _DateTimeFormat(_NowCalc(), 4))
GUICtrlSetBkColor($Server3, 0xff0000)
GUICtrlSetBkColor($Output3, 0xff0000)
else
GuiCtrlSetData($Output3, $config_server3 & " is ok " &@CRLF& _DateTimeFormat(_NowCalc(), 2) &" - "& _DateTimeFormat(_NowCalc(), 4))
GUICtrlSetBkColor($Server3, 0x8fff89)
GUICtrlSetBkColor($Output3, 0xdddddd)
EndIf
EndFunc
Func _ServerCheck()
$socket1 = TCPConnect($config_serverip, $config_server1port)
If $socket1 = -1 Then
GuiCtrlSetData($Output1, $config_server1 & " is down " &@CRLF& _DateTimeFormat(_NowCalc(), 2) &" - "& _DateTimeFormat(_NowCalc(), 4))
GUICtrlSetBkColor($Server1, 0xff0000)
else
GuiCtrlSetData($Output1, $config_server1 & " is ok " &@CRLF& _DateTimeFormat(_NowCalc(), 2) &" - "& _DateTimeFormat(_NowCalc(), 4))
GUICtrlSetBkColor($Server1, 0x8fff89)
EndIf
$socket2 = TCPConnect($config_serverip, $config_server2port)
If $socket2 = -1 Then
GuiCtrlSetData($Output2, $config_server2 & " is down " &@CRLF& _DateTimeFormat(_NowCalc(), 2) &" - "& _DateTimeFormat(_NowCalc(), 4))
GUICtrlSetBkColor($Server2, 0xff0000)
else
GuiCtrlSetData($Output2, $config_server2 & " is ok " &@CRLF& _DateTimeFormat(_NowCalc(), 2) &" - "& _DateTimeFormat(_NowCalc(), 4))
GUICtrlSetBkColor($Server2, 0x8fff89)
EndIf
$socket3 = TCPConnect($config_serverip, $config_server3port)
If $socket3 = -1 Then
GuiCtrlSetData($Output3, $config_server3 & " is down " &@CRLF& _DateTimeFormat(_NowCalc(), 2) &" - "& _DateTimeFormat(_NowCalc(), 4))
GUICtrlSetBkColor($Server3, 0xff0000)
else
GuiCtrlSetData($Output3, $config_server3 & " is ok " &@CRLF& _DateTimeFormat(_NowCalc(), 2) &" - "& _DateTimeFormat(_NowCalc(), 4))
GUICtrlSetBkColor($Server3, 0x8fff89)
EndIf
EndFunc
Func ExitApp()
Exit
EndFunc
Alles anzeigen
config.ini