Detecting a window that is "Not Responding"
Detecting a window that is "Not Responding"
How do you detect a window that is "Not Responding" on windows 7 and windows 8/8.1 and then take action to shut that window down?
The world and human nature was screwed up before I was born. It's not my fault and I'm just stuck with trying to deal with the mess left behind, so don't blame me.
Re: Detecting a window that is "Not Responding"
Never mind.
Last edited by PB on Sat Nov 15, 2014 3:51 pm, edited 1 time in total.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
- Teddy Rogers
- User

- Posts: 98
- Joined: Sun Feb 23, 2014 2:05 am
- Location: Australia
- Contact:
Re: Detecting a window that is "Not Responding"
You could do something like this, maybe?
Ted.
Code: Select all
If SendMessageTimeout_(hWnd, #WM_NULL, #Null, #Null, #SMTO_ABORTIFHUNG, 1000, #Null)
Debug "We can still communicate with the window..."
Else
GetWindowThreadProcessId_(hWnd, @lpdwProcessId)
hWndProcess = OpenProcess_(#PROCESS_ALL_ACCESS, #True, lpdwProcessId)
If hWndProcess
TerminateProcess_(hWndProcess, #Null)
CloseHandle_(hWndProcess)
EndIf
EndIfRe: Detecting a window that is "Not Responding"
There is a API called IsHungAppWindow().
Not tested, but it should work this way:
Not tested, but it should work this way:
Code: Select all
Prototype pIsHungAppWindow(hwnd)
yourhwnd = FindWindow_(0, "title")
OpenLibrary(0, "user32.dll")
IsHungAppWindow_.pIsHungAppWindow = GetFunction(0, "IsHungAppWindow")
Debug IsHungAppWindow_(yourhwnd)
CloseLibrary(0)- Teddy Rogers
- User

- Posts: 98
- Joined: Sun Feb 23, 2014 2:05 am
- Location: Australia
- Contact:
Re: Detecting a window that is "Not Responding"
I wouldn't use IsHungAppWindow. I find SendMessageTimeout works much better and is more reliable at detecting hung applications or those that are suspended. IsHungAppWindow is also listed on MSDN as being marked for removal in a future version of Windows...
Ted.
Ted.

