Sign in to follow this  
Followers 0
lostom

Close a frozen/hung program

10 posts in this topic

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.

Share this post


Link to post
Share on other sites



"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?

Share this post


Link to post
Share on other sites

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).

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Well that is good to hear. If you have any more problems, fel free to PM me.

Share this post


Link to post
Share on other sites

#9 ·  Posted (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 by monoscout999

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0