lostom Posted July 24, 2011 Share Posted July 24, 2011 Good evening, I was searching for a script that closes a program when it's not responding, and I found one. The problem is, that a few things are unclear for me. This is the script: ; finding if an application is hung ; neogia If _NotResponding("TITLE HERE", "TEXT HERE[OPTIONAL]", 1) Then; The last parameter indicates whether you want to close the hung app or not. MsgBox(0,"", "Hung Application, closing app now.") Else MsgBox(0,"", "Application running as intended.") EndIf Func _NotResponding($title, $text, $closeIfHung = 0) $hWnd = WinGetHandle($title, $text) If $hWnd == "" 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 I don't really know what to do with this, and then espescially the last part, the "text here", as the "title here" is just the process title if I'm right which shows in the upper bar if I'm right This is the part: If _NotResponding("TITLE HERE", "TEXT HERE[OPTIONAL]", 1) Then; The last parameter indicates whether you want to close the hung app or not. Also, is it possible to add a kind of delay before the process gets killed, as the program sometimes doesn't respond for like 30 seconds, but after those 30, it works again. Thanks in advantage. Link to comment Share on other sites More sharing options...
JohnOne Posted July 24, 2011 Share Posted July 24, 2011 You could put it in a loop I suppose. Do Until _NotResponding($title, $text, $closeIfHung = 1) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Mikeman27294 Posted July 24, 2011 Share Posted July 24, 2011 "Title Here" is where you put the name of the application. As for making a delay, I would place a sleep(30000) command right above the ProcessClose(WinGetProcess($Title,$Text)ProcessClose(WinGetProcess($title, $text). As for whether it works or not, is a completely different story, but if it doesnt, I would be extremely surprised.Also, I dont see what is wrong with ending the process fron task manager? Link to comment Share on other sites More sharing options...
lostom Posted July 24, 2011 Author Share Posted July 24, 2011 Also, I dont see what is wrong with ending the process fron task manager?Thanks for the responds, I guess that I can do something with that.And about the thing above, I'm not monitoring the process 24/7, so it needs to be closed if it's frozen (it gets restarted automaticly). Link to comment Share on other sites More sharing options...
monoscout999 Posted July 24, 2011 Share Posted July 24, 2011 i don`t know how you get the title of the window but you can use instead of title the window hwnd and leave the text parameter as "". Or getting the PID from the process directly Link to comment Share on other sites More sharing options...
Mikeman27294 Posted July 25, 2011 Share Posted July 25, 2011 Wait... do you mean you are or arent running it 24/7? Because I dont get why you would need a script if you are not running it 24/7, because task manager would do it for one that is not running it 24/7. Anyway, did it work? Link to comment Share on other sites More sharing options...
lostom Posted July 25, 2011 Author Share Posted July 25, 2011 Wait... do you mean you are or arent running it 24/7? Because I dont get why you would need a script if you are not running it 24/7, because task manager would do it for one that is not running it 24/7. Anyway, did it work?I am running the program 24/7, but I'm not monitoring it 24/7 (as in watching if it's still online).And it seems to work, as the program hasn't been frozen again when I looked at it. Link to comment Share on other sites More sharing options...
Mikeman27294 Posted July 26, 2011 Share Posted July 26, 2011 Well that is good to hear. If you have any more problems, fel free to PM me. Link to comment Share on other sites More sharing options...
monoscout999 Posted July 26, 2011 Share Posted July 26, 2011 (edited) Well that is good to hear. If you have any more problems, fel free to PM me.This is public forum, why PM to you? Post it here where we all can see it. Edited July 26, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
Mikeman27294 Posted July 27, 2011 Share Posted July 27, 2011 Yeah, but I just wanted to let you know that if you feel that you dont want to make it public, you can PM me. 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