in reply to Applications running status in Windows Task Manager
"Not Responding" appears in the title bar of the program while Task manager showing 'not responding' status. Using this fact you can detect if your program is in 'not responding' status.
Set $NOT_RESPONDING variable accordingly your application title.
use strict; use warnings; use Win32::API; my $NOT_RESPONDING = 'Your App (Not Responding)'; use constant GW_CHILD => 5; use constant GW_HWNDNEXT => 2; Win32::API->Import('user32', 'HWND GetDesktopWindow()'); Win32::API->Import('user32', 'HWND GetWindow(HWND hWnd, UINT uCmd)'); Win32::API->Import('user32', 'GetWindowText', 'LPi', 'i'); my $hwnd = GetDesktopWindow(); $hwnd = GetWindow($hwnd, GW_CHILD); while ($hwnd) { $hwnd = GetWindow($hwnd, GW_HWNDNEXT); my $title = 'x' x 256; GetWindowText($hwnd, $title, length($title) - 1); if ($title =~ /\Q$NOT_RESPONDING/) { print "Detected: $NOT_RESPONDING\n"; } }
I am not on Windows now and can't test if the script runs without errors. But I hope it will be helpful.
|
|---|