Ever happened to you to have blocked app? Window just stopped responding? In AutoIt there isn't much to do when that happens. Just wait or manually kill your app. Embarrassing for you as coder, surly ...Should be. What about this. I register internal handler and when my app hangs next time, I deal with that the way I like it. Maybe try to unblock it or notice the behavior for the future or simply exit, whatever... This UDF gives you ability to register function to call when app stops responding. Placeholder for the function is defined as (name is irrelevant): Func _OnHungApp($iParam1, $iParam2)
EndFunc Parameters are: $iParam1 - lparam DllCall type$iParam2 - wparam DllCall typeSo you can pass whatever you want to the function. Default is 0, 0. Handler works differently depending on what you return from _OnHungApp(). Three possibilities: In case you return $HUNGAPP_EXITHANDLER (0/False) handler will no longer be run. This is also the case if you don't specify any return value.If you return $HUNGAPP_EXITPROCESS (1/True) you will exit the app with the exit code you specified when registering handler. By returning $HUNGAPP_CONTINUEHANDLER (259) handler continues handling.Unregistering and freeing resources is done by _OnHungAppUnRegister() function. It's optional. Handler is very low on requirements. Registering is done after you create your GUI (need that handle) or if your app is GUI-less then pass something like: WinGetHandle(AutoItWinGetTitle())Function definition is: _OnHungAppRegister($hWnd, $sFunction[, $iInterval = Default[, $vParam1 = Default[, $vParam2 = Default[, $iExitCode = Default]]]])Description for parameters: $hWnd - A handle to the window to be monitored. $sFunction - Function to call when 'not responding' state is detected. $iInterval - Optional time interval in which to repeat the tesing. Default is 1000 ms (1sec). $vParam1 - Optional parameter to pass to the function (lparam). Default is 0. $vParam2 - Optional parameter to pass to the function (wparam). Default is 0. $iExitCode - Optional exit code for the app to return. Default is 0. Another function is _OnHungAppRegisterEx. That one works slightly different. The benefits are that you can choose time value at which _OnHungApp() will be called. This is more advanced approach since you are in complete control. That one is defined as: _OnHungAppRegisterEx($hWnd, $sFunction[, $iHungAppTime = Default[, $vParam1 = Default[, $vParam2 = Default[, $iExitCode = Default]]]])Parameters: $hWnd - A handle to the window to be monitored. $sFunction - Function to call when 'not responding' state is detected. $iHungAppTime - Optional time value in ms at which window will be flagged as unresponding one. Default is 5000 ms. Minimum is 500 ms. $vParam1 - Optional parameter to pass to the function (lparam). Default is 0. $vParam2 - Optional parameter to pass to the function (wparam). Default is 0. $iExitCode - Optional exit code for the app to return. Default is 0. $iInterval - Optional time interval in which to repeat the tesing. Default is 250 ms. Script with few examples: OnHungApp.zip