 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
evl
Joined: 24 Aug 2005 Posts: 1237
|
Posted: Sat Sep 22, 2007 2:37 pm Post subject: Not Responding - check a window's status |
|
|
An example of how to check if a Calculator window (or any other window you substitute) is responding or not responding (hung or crashed).
I know there's been a post in the forum before about a similar script, but I found this one to respond more quickly in all situations.
| Code: |
; /*
; * SendMessageTimeout values
;
; #define SMTO_NORMAL 0x0000
; #define SMTO_BLOCK 0x0001
; #define SMTO_ABORTIFHUNG 0x0002
; #if(WINVER >= 0x0500)
; #define SMTO_NOTIMEOUTIFNOTHUNG 0x0008
; #endif /* WINVER >= 0x0500 */
; #endif /* !NONCMESSAGES */
;
;
; SendMessageTimeout(
; __in HWND hWnd,
; __in UINT Msg,
; __in WPARAM wParam,
; __in LPARAM lParam,
; __in UINT fuFlags,
; __in UINT uTimeout,
; __out_opt PDWORD_PTR lpdwResult);
; */
NR_temp =0 ; init
TimeOut = 100 ; milliseconds to wait before deciding it is not responding - 100 ms seems reliable under 100% usage
; WM_NULL =0x0000
; SMTO_ABORTIFHUNG =0x0002
WinGet, wid, ID, Calculator ; retrieve the ID of a window to check
Responding := DllCall("SendMessageTimeout", "UInt", wid, "UInt", 0x0000, "Int", 0, "Int", 0, "UInt", 0x0002, "UInt", TimeOut, "UInt *", NR_temp)
If Responding = 1 ; 1= responding, 0 = Not Responding
Msgbox, Responding
Else
Msgbox, Not Responding
|
|
|
| Back to top |
|
 |
rortiz77
Joined: 17 Oct 2008 Posts: 1
|
Posted: Fri Oct 17, 2008 6:36 pm Post subject: Doesn't seem to work... |
|
|
Hi,
I'm trying to run an auto delete script on my app but I'm running into a problem where after a few deletes it will freeze up the window...it'll say on the top bar "Address Book #1 - ASG-Cypress (Not Responding)" Is there a way to have the script "know" when it's in the "Not Responding" state and have the script wait until it resumes and then after it's back continue with the loop and delete the rest?
Here's my script:
| Code: | loop, 500
{
WinWait, Address Book #1 - ASG-Cypress,
IfWinNotActive, Address Book #1 - ASG-Cypress, , WinActivate, Address Book #1 - ASG-Cypress,
WinWaitActive, Address Book #1 - ASG-Cypress,
MouseClick, left, 299, 17
Sleep, 100
MouseClick, left, 536, 223
Sleep, 100
WinWait, UI,
IfWinNotActive, UI, , WinActivate, UI,
WinWaitActive, UI,
MouseClick, left, 209, 92
Sleep, 90000
} |
|
|
| Back to top |
|
 |
evl
Joined: 24 Aug 2005 Posts: 1237
|
Posted: Sat Oct 18, 2008 1:15 am Post subject: |
|
|
Try the following (untested) - substitute in your own program's title:
| Code: | NR_temp =0 ; init
TimeOut = 100 ; milliseconds to wait before deciding it is not responding - 100 ms seems reliable under 100% usage
; WM_NULL =0x0000
; SMTO_ABORTIFHUNG =0x0002
WinGet, wid, ID, Calculator ; retrieve the ID of a window to check
Loop
{
Global NR_temp, TimeOut, wid
Responding := DllCall("SendMessageTimeout", "UInt", wid, "UInt", 0x0000, "Int", 0, "Int", 0, "UInt", 0x0002, "UInt", TimeOut, "UInt *", NR_temp)
If Responding = 1 ; 1= responding, 0 = Not Responding
Break
Sleep, 500 ; wait half a second before trying again
} |
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|