Jump to content

how to know if a process is not responding?


Recommended Posts

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

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

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

Other than the obvious that this program closes a hung app, maybe an elaboration on it :(

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...