CoDeX2k Posted July 31, 2006 Posted July 31, 2006 Hi @ all, i have a little question. I created a GUI to monitor a Service. The GUI Displays the Status of the Service and the Server. It should ping the server all 60 seconds and look if a process still exists all 120 seconds. But you sould also can click on the GUI Buttons. Where should i put the code for checking this stuff? Because if i put it "Case Else" the GUI is blocked for 60 seconds... Thanks for helping me. Regards, CoDeX2k
BabyBeast Posted July 31, 2006 Posted July 31, 2006 not sure of yourcode but 60sec or not you can use guisetdata to make changes on your gui while in the time loop and checking for your service
CoDeX2k Posted July 31, 2006 Author Posted July 31, 2006 not sure of yourcode but 60sec or not you can use guisetdata to make changes on your gui while in the time loop and checking for your serviceYeah, i allready use GUISETData. But i can't checking it while using the GUI :-( If i check i can't use the GUI. If i use the GUI i can't check...regards,
CoDeX2k Posted July 31, 2006 Author Posted July 31, 2006 I can't get it work display the status and buttons and check in the background the availibility of an ip with ping... and processexist("service.exe") for the service. If i do it like this Case Else Sleep(60000) _CheckService() EndSelect I can't close or control the form in this 60 seconds... Anybody an idea? Thanks Regards, CoDeX2k
Skruge Posted August 1, 2006 Posted August 1, 2006 Don't use such a big sleep. Look at the Timer functions and only act when your desired interval is reached. [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]
kjmarket Posted August 1, 2006 Posted August 1, 2006 Showing a little more code would probably help people to help you. Pink Floyd - The Wall
CoDeX2k Posted August 1, 2006 Author Posted August 1, 2006 Okay, i post the hole code of the Script expandcollapse popup; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.1.1.130 BETA ; Author: CoDeX2k <codex2k@gmx.net> ; ; ;Service Monitor ; ; ---------------------------------------------------------------------------- #include <GUIConstants.au3> $frmStatus = GUICreate("Service Monitor", 183, 98, 413, 232,-1,-1) GUICtrlCreateLabel("Service Status:", 8, 8, 66, 17) If ProcessExists("service.exe")=0 Then $servicestatus=GUICtrlCreateLabel("Stopped", 80, 8, 84, 20) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) Else $servicestatus=GUICtrlCreateLabel("Running", 80, 8, 84, 20) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x008000) EndIf $btnShutdown = GUICtrlCreateButton("Shutdown", 8, 64, 75, 25) $btnRestart = GUICtrlCreateButton("Restart", 96, 64, 75, 25) Opt("TrayIconHide", 1) GUICtrlCreateLabel("Internet Status:", 8, 32, 71, 17) If Ping("www.google.de")>0 Then $internetstatus=GUICtrlCreateLabel("Up", 80, 32, 100, 20) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x008000) Else $internetstatus=GUICtrlCreateLabel("Down", 80, 32, 100, 20) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) EndIf GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $btnShutdown ;Shutdown Case $msg = $btnRestart ;Restart Case Else _CheckInternetConnection() _CheckServiceStatus() EndSelect WEnd Func _CheckInternetConnection() Sleep(60000) If Ping("www.google.de")>0 Then GUICtrlSetData($internetstatus,"Up") GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x008000) Else GUICtrlSetData($internetstatus,"Down") GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) EndIf EndFunc Func _CheckServiceStatus() Sleep(120000) If ProcessExists("service.exe")=0 Then GUICtrlsetdata($servicestatus,"Stopped") GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) Else GUICtrlSetData($servicestatus,"Running") GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x008000) EndIf EndFunc Regards, CoDeX2k
Moderators SmOke_N Posted August 1, 2006 Moderators Posted August 1, 2006 expandcollapse popupGlobal $iKeepCount #include <GUIConstants.au3> AdlibEnable('_AdlibManager', 60000) $frmStatus = GUICreate("Service Monitor", 183, 98, 413, 232,-1,-1) GUICtrlCreateLabel("Service Status:", 8, 8, 66, 17) If ProcessExists("service.exe")=0 Then $servicestatus=GUICtrlCreateLabel("Stopped", 80, 8, 84, 20) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) Else $servicestatus=GUICtrlCreateLabel("Running", 80, 8, 84, 20) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x008000) EndIf $btnShutdown = GUICtrlCreateButton("Shutdown", 8, 64, 75, 25) $btnRestart = GUICtrlCreateButton("Restart", 96, 64, 75, 25) Opt("TrayIconHide", 1) GUICtrlCreateLabel("Internet Status:", 8, 32, 71, 17) If Ping("www.google.de")>0 Then $internetstatus=GUICtrlCreateLabel("Up", 80, 32, 100, 20) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x008000) Else $internetstatus=GUICtrlCreateLabel("Down", 80, 32, 100, 20) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) EndIf GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $btnShutdown ;Shutdown Case $msg = $btnRestart ;Restart Case Else _CheckInternetConnection() _CheckServiceStatus() EndSelect WEnd Func _AdlibManager() $iKeepCount = $iKeepCount + 1 _CheckInternetConnection() If $iKeepCount = 2 Then _CheckServiceStatus() $iKeepCount = 0 EndIf EndFunc Func _CheckInternetConnection() If Ping("www.google.de") Then GUICtrlSetData($internetstatus,"Up") GUICtrlSetFont($internetstatus, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor($internetstatus, 0x008000) Else GUICtrlSetData($internetstatus,"Down") GUICtrlSetFont($internetstatus, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor($internetstatus, 0xFF0000) EndIf EndFunc Func _CheckServiceStatus() If Not ProcessExists("service.exe") Then GUICtrlsetdata($servicestatus,"Stopped") GUICtrlSetFont($servicestatus, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor($servicestatus, 0xFF0000) Else GUICtrlSetData($servicestatus,"Running") GUICtrlSetFont($servicestatus, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor($servicestatus, 0x008000) EndIf EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
CoDeX2k Posted August 1, 2006 Author Posted August 1, 2006 Thanks a lot works very well. You are my AutoIT Hero =))))
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now