Skip to content

Instantly share code, notes, and snippets.

@TheDcoder
Last active December 6, 2017 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheDcoder/ab25ba0677cb38c502a23b274393b161 to your computer and use it in GitHub Desktop.
Save TheDcoder/ab25ba0677cb38c502a23b274393b161 to your computer and use it in GitHub Desktop.
IsWindowNotResponding
#include <WinAPISys.au3>
; #FUNCTION# ====================================================================================================================
; Name ..........: IsWindowNotResponding
; Description ...: Checks if a Window is not responding
; Syntax ........: IsWindowNotResponding($hWindow[, $iTimeout = 5000])
; Parameters ....: $hWindow - A window handle.
; $iTimeout - [optional] Shouldn't matter, Timeout in milliseconds. Default is 5000.
; Return values .: @error set by _WinAPI_SendMessageTimeout
; Author ........: Damon Harris (TheDcoder)
; Remarks .......: The way it works is that it exploits SendMessageTimeout's SMTO_ABORTIFHUNG option.
; Do more research on Process.Responding and how it works (C# function for checking if a window is responding)
; Link ..........: https://git.io/vbcvJ
; Example .......: If IsWindowNotResponding($hWindow) Then DoSomething()
; ===============================================================================================================================
Func IsWindowNotResponding($hWindow, $iTimeout = 5000)
_WinAPI_SendMessageTimeout($hWindow, 0, 0, 0, $iTimeout, $SMTO_ABORTIFHUNG)
Return @error
EndFunc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment