Modify

Opened 10 years ago

Closed 10 years ago

#1294 closed Bug (Fixed)

WinGetTitle freezes script when reading the title of a suspended/hanged process

Reported by: marc0v Owned by: Jon
Milestone: 3.3.1.6 Component: AutoIt
Version: 3.3.0.0 Severity: None
Keywords: Hanged Process Freeze Cc:

Description

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.

Attachments (0)

Change History (8)

comment:1 Changed 10 years ago by TicketCleanup

  • Version 3.3.0.0 deleted

Automatic ticket cleanup.

comment:2 Changed 10 years ago by Valik

  • Type changed from Feature Request to Bug
  • Version set to 3.3.0.0

I'm pretty sure this behavior is a bug if it's true.

comment:3 Changed 10 years ago by marc0v

More testing seems to show that WinSetTitle, WinGetText, WinFlash, WinSetOnTop are affected the same way,
but NOT WinGetState, WinGetPos, WinGetProcess, WinGetHandle, WinSetState, WinExists, WinList, WinWait.
I only tested the most usual functions.

comment:4 Changed 10 years ago by Valik

  • Severity changed from None to Blocking

comment:5 Changed 10 years ago by AdmiralAlkex

Just as a reminder here; this is an old issue that has been talked about in the forum atleast once. See topic 97196 http://www.autoitscript.com/forum/index.php?showtopic=97196

comment:6 Changed 10 years ago by marc0v

After reading the above comment WinSetState is also affected, if trying to set the state of the window to something else than the current state (that is, trying to change the state of the targeted suspended window).

I forgot to mention my testing where done with : WinXP SP3 and AutoIT 3.3.0.0

comment:7 Changed 10 years ago by Valik

  • Severity changed from Blocking to None

comment:8 Changed 10 years ago by Jon

  • Milestone set to 3.3.1.6
  • Owner set to Jon
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [5412] in version: 3.3.1.6

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Jon.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.