Detecting a window that is "Not Responding"
Posted: Sat Nov 15, 2014 12:08 pm
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?
http://www.purebasic.com
https://www.purebasic.fr/english/
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
EndIfCode: Select all
Prototype pIsHungAppWindow(hwnd)
yourhwnd = FindWindow_(0, "title")
OpenLibrary(0, "user32.dll")
IsHungAppWindow_.pIsHungAppWindow = GetFunction(0, "IsHungAppWindow")
Debug IsHungAppWindow_(yourhwnd)
CloseLibrary(0)