![]() |
|
[AutoIt]Code for Restarter - Printable Version +- LCKB (https://lckb.dev/forum) +-- Forum: ** OLD LCKB DATABASE ** (https://lckb.dev/forum/forumdisplay.php?fid=109) +--- Forum: Programmers Gateway (https://lckb.dev/forum/forumdisplay.php?fid=196) +---- Forum: Coders Talk (https://lckb.dev/forum/forumdisplay.php?fid=192) +---- Thread: [AutoIt]Code for Restarter (/showthread.php?tid=684) |
- Nikolee - 02-21-2012 I have atm this code, that Start lcsm if this not exist in taskmngr. While 1 While ProcessExists("lcsm.exe") ----> Here can be Connector.exe too. Sleep(100) WEnd Sleep(30) Run( "lcsm") Do Sleep(100) Until ProcessExists("lcsm.exe") WEnd But, i wanna to write a Programm, who restart the Server then the Connector or/and Gameserver Crashs. A Friend send me something like this : f _NotResponding("C:\Users\Desktop\LCSM\Connector\Connector.exe", 1) Then; The last parameter indicates whether you want to close the hung app or not. MsgBox(0,"Restart Server", "Restart Biw") Else MsgBox(0,"", "Application running as intended.") EndIf Func _NotResponding($title, $text, $closeIfHung = 0) $hWnd = WinGetHandle($title, $text) If $hWnd == "C:\Users\Desktop\LCSM\Connector\Connector.exe" Then MsgBox(0,"Error","Could not find window") Exit EndIf $retArr = DllCall("user32.dll", "int", "IsHungAppWindow", "hwnd", $hWnd) If @error == 0 Then If $retArr[0] == 1 Then If $closeIfHung Then ProcessClose(WinGetProcess($title, $text)) EndIf Return 1 EndIf Else Return 0 EndIf EndFunc But i cant handle with it i wanna a simple script^^ - someone - 02-21-2012 First thing you forgot to write [AutoIt] on your title tag. Your code has some problems. 1)It looks for LCSM.exe not Connector.exe 2)When the Connector is crashing will not close(the process will remain there). 3)You dont need this, because you have your second while: Do Sleep(100) Until ProcessExists("lcsm.exe") 3)look if the Process is working using the code your fried gave you: fisrt you need to get the process Handle, using WinGetProcess();: Then you need to check the the process i s hung up(your friend gave you the code): $retArr = DllCall("user32.dll", "int", "IsHungAppWindow", "hwnd", $hWnd); If retArr then ProcessClose("Connector.exe"); Run( "Connector.exe") EndIf - Nikolee - 02-22-2012 what must be $hWnd ? - someone - 02-22-2012 $Hwnd is the window handler, needed to check. func getHandle($pid) $list = WinList() for $i = 1 to $list[0][0] if(WinGetProcess($list[$i][1]) = $pid) Then return $list[i][1] endIf Next return 0 endFunc - Nikolee - 02-22-2012 Thank you for Help i generate my own with ProcessClose and then start lcsm ![]() - kimmer01 - 03-18-2012 how i can use it ?? - Nikolee - 03-20-2012 i make a new at the moment that handle with OllyDbg - Wizatek - 03-20-2012 It may not have anything to do with programming or with autoit, but i personally use : 2 that free program to monitor my processes. btw, someone, is there any language u dont know ? :O - Nikolee - 03-20-2012 Thanks you Wiza^^ - Koko - 03-20-2012 btw, someone, is there any language u dont know ? :O Im sure he doesnt speak japanese yet. (please tell me im right) |