﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
1294	WinGetTitle freezes script when reading the title of a suspended/hanged process	marc0v	Jon	"Not really a bug, so it is a feature request...

If an autoit script tries to do WinGetTitle on an existing window which is part of a suspended/hanged process then the autoit script freezes.

The request is to have WinGetTitle return 0 or -1 if the targeted window/process doesn't respond, maybe with a time-out, instead of freezing the running script.

Suspending a process requires a third party tool like Process Explorer, freeware from microsoft :
[http://download.sysinternals.com/Files/ProcessExplorer.zip]
Hanging a process is more difficult unless you have a buggy app.

In the example below the process targeted with WinGetTitle (the second script) is also an autoit process (but could be any process).

First, start both scripts,
then suspend the second script with Process Explorer,
the first autoit script will then freeze until the second is resumed or closed.

The first autoit script :
{{{
AutoItSetOption(""MustDeclareVars"", 1)

#include <GUIConstantsEx.au3>

Example()

Func Example()
	Local $id_label, $myvar, $msg, $timer, $nowdiff, $lastupdatediff
	Const $ms_update_interval = 100

	GUICreate(""My GUI"")
	$id_label = GUICtrlCreateLabel(""text"", 10, 10, 300, 20)
	GUISetState()

	$timer = TimerInit()
	$lastupdatediff = 0

	While 1
		$msg = GUIGetMsg()
		If $msg = $GUI_EVENT_CLOSE Then ExitLoop

		$nowdiff = TimerDiff($timer)
		$myvar = ""Title GUI2:"" & WinGetTitle(""My GUI2"") & "" ("" & Int($nowdiff / 1000) & ""s)""
		If ($nowdiff - $lastupdatediff >= $ms_update_interval) Then
			If Not(GUICtrlRead($id_label) == $myvar) Then GUICtrlSetData($id_label, $myvar)
			$lastupdatediff = $nowdiff
		EndIf
	WEnd
EndFunc
}}}

The targeted process to suspend manually :
{{{
AutoItSetOption(""MustDeclareVars"", 1)

#include <GUIConstantsEx.au3>

Example()

Func Example()
	Local $id_label, $myvar, $msg, $timer, $nowdiff, $lastupdatediff
	Const $ms_update_interval = 100

	GUICreate(""My GUI2"")
	$id_label = GUICtrlCreateLabel(""text"", 10, 10, 100, 20)
	GUISetState()

	$timer = TimerInit()
	$lastupdatediff = 0

	While 1
		$msg = GUIGetMsg()
		If $msg = $GUI_EVENT_CLOSE Then ExitLoop

		$nowdiff = TimerDiff($timer)
		$myvar = Int($nowdiff / 1000) & ""s""
		If ($nowdiff - $lastupdatediff >= $ms_update_interval) Then
			If Not(GUICtrlRead($id_label) == $myvar) Then GUICtrlSetData($id_label, $myvar)
			$lastupdatediff = $nowdiff
		EndIf
	WEnd
EndFunc
}}}

Note : the problem doesn't occur if :
the second script is started first,
then is suspended,
and then the first script is started.
"	Bug	closed	3.3.1.6	AutoIt	3.3.0.0	None	Fixed	Hanged Process Freeze	
