Bella Posted March 31, 2007 Share Posted March 31, 2007 (edited) Greetings everyone. i must say i love this program i only have about 2 days experence and ive coded most of it myself anyways im working on an autorestarter.. yeah i know this sounds lame and easy but it isnt you see when this exe "Mangosd.exe" crashes. it doesnt close. it sits there. so what i figured i do is scan the Server.log for a string like " Haulting process" if that exists then delete the server.log and restart the exe... simple right? /cry heres my code. expandcollapse popup; search.au3 ; usage search.exe filename searchword #include <Sound.au3> #include <GUIConstants.au3> Global Const $ProcessCheck = ProcessExists("realmd.exe") Global Const $ProcessEnd = ProcessClose("realmd.exe") Global Const $Crash = RunWait('find "Halting process..." "Server.log","",@SW_HIDE') Global Const $Delete = FileDelete("mangos.log") Global Const $aim = ProcessExists("Aim.exe") Global Const $Serverlog = FileOpen("server.log", 0) ;======================================================================= ; Checking if mangos is running , if = 1, Kill Mangosd.exe | ;======================================================================= #include <GUIConstants.au3> GUICreate("Mangos Mastermind v2.0.01") Opt("GUICoordMode",2) $Button_1 = GUICtrlCreateButton ("Run World server", 10, 30, 100) $Button_2 = GUICtrlCreateButton ( "Run Realm server", 0, -1) $Button_3 = GUICtrlCreateButton ( "Clear Server.log", 0, -1) $Button_4 = GUICtrlCreateButton ( "Crash Handler", 0, -1) GUISetState () ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 Run("Mangosd.exe") Case $msg = $Button_2 Run("realmd.exe") Case $msg = $Button_3 FileDelete("Server.log") MsgBox(0, 'Mangos Mastermind', '"Server.log" Secussfully Cleaned!') Case $msg = $Button_4 Logcheck($Serverlog) EndSelect Wend ;======================================================================= ; Crash Detector | ;======================================================================= ;======================================================================= ; Functions ;======================================================================= Func Crashcheck($Crash) Select Case $Crash = 1 Msgbox(4096,"",'Yep.. its there.') Case $Crash = 0 Msgbox(4096,"",'nope were aids free.') EndSelect EndFunc Func ReadLog($processCheck) Select Case $ProcessCheck = 0 MsgBox(4096,"",'Realm server not detected.') Case $ProcessCheck = 1 MsgBox(4096,"",'Realm server already online.') EndSelect EndFunc Func Logcheck($Serverlog) Select Case $Serverlog = 0 MsgBox(4096,"",'Server.log Is missing.') Case $Serverlog = 1 MsgBox(4096,"",'Server.Log is HERE!.') EndSelect EndFunc its really messy i know, but please have some paitentce i might be of use to the forms later some day and also if i may ask, please dont bash me if im doing something way to hard or stupid, it would be nice just to know that you have a better, more efficient way <3 --bella Edited March 31, 2007 by Bella Link to comment Share on other sites More sharing options...
_Kurt Posted April 1, 2007 Share Posted April 1, 2007 (edited) First of all, I'd like to congratulate you on making some sort of effort before posting a question. After going through your script, I realized I could spend a lot of time discussing how to fix up your script. I will tell you the obvious mistakes you made.Firstly, If you want to check for something every X seconds, you cannot state it as a Global Const. Instead, you must put it inside your While..WEnd loop. So, to cut to the chase, delete all your Global Const's. It should look something like this.. I wrote this up for you, however it took me half a minute so don't think I'm that generous.$timer = TimerInit() While 1 If TimerDiff($timer) > 10000 Then ;Every 10 seconds, we do the following: $FileRead = FileRead("server.log") ;$FileRead contains the characters in the file If StringInStr($FileRead, "Halting process...") Then MsgBox(0,"","PROCESS IS HALTED!!") Else MsgBox(0,"","PROCESS IS NOT HALTED") EndIf $timer = 0 $timer = TimerInit() EndIfoÝ÷ Ù¦zfÞ®ØZ¶Ø^±Êâ¦Ù®²ÖÞ{azÇ«½êå¢bç-¢¼Ø^®ØZ¶ò¢é®²×!jx¶W©jØ@Ê$yêbh§vØZ¶Øb²+(ëh¦«¶ò¢êÖ)^XIÝ)2â '"ÇÊ·ö÷®±çmçèZ0x-Â'|¨º»®*mjëh×6#Include <GUIConstants.au3>This should be only used once (preferrably at the start of your script with your other #Include's). For more information on declaring variable's, look in the helpfile (press F1 in SciTe for quick-access). Well there are most of your problems, glad to get that off my chest. Post any more problems you experience and we* will be glad to help.Good Luck,Kurt*please note that not all members of this forum will gladly give you suggestions & example scripts.. So use the helpfile EDIT: Forgot to declare $timer variable Edited April 1, 2007 by _Kurt Awaiting Diablo III.. Link to comment Share on other sites More sharing options...
Bella Posted April 1, 2007 Author Share Posted April 1, 2007 omgawd, i have a big e-crush on you ^^ thanks soooo much i totally apprechate it Link to comment Share on other sites More sharing options...
Bella Posted April 1, 2007 Author Share Posted April 1, 2007 Well since you have given to me I shall give back to the communitity $timer = TimerInit() While 1 If TimerDiff($timer) > 10000 Then;Every 10 seconds, we do the following: $FileRead = FileRead("server.log");$FileRead contains the characters in the file If StringInStr($FileRead, "Halting process...") Then $destination = "downarrow2.gif" SplashImageOn("Online", $destination, 32, 34, "", "", 1) ProcessClose("mangosd.exe") Run("mangosd.exe") Else $destination = "uparrow2.gif" SplashImageOn("Online", $destination, 32, 34, "", "", 1) EndIf $timer = 0 $timer = TimerInit() EndIf WEnd now Basically what this program does is checks the current Directory for an exe called Mangosd.exe which is an emulator for a private world of warcraft server. it also reads the output it logs to server.log, and then checks if there was an error with mangos. if the error exist it will close mangos then, reopen it. Mangos clears the server log each restart so no need for a delete funct. anyways just throw two images in there. one for an online status, than one for a offline Again this code can be modified to work for anything. Anyways thanks so much again. i really apprechate it and i hope i dont piss you off by saying i love you again. i am extremly greatfull Link to comment Share on other sites More sharing options...
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