AutoHotkey Community

It is currently May 25th, 2012, 4:21 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: September 22nd, 2007, 3:37 pm 
Offline

Joined: August 24th, 2005, 5:17 pm
Posts: 1237
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Doesn't seem to work...
PostPosted: October 17th, 2008, 7:36 pm 
Offline

Joined: October 17th, 2008, 7:28 pm
Posts: 1
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
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 18th, 2008, 2:15 am 
Offline

Joined: August 24th, 2005, 5:17 pm
Posts: 1237
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
}


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher, sarevok9 and 23 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group