Opened 16 years ago
Closed 16 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 by , 16 years ago
| Version: | 3.3.0.0 |
|---|
comment:2 by , 16 years ago
| Type: | Feature Request → Bug |
|---|---|
| Version: | → 3.3.0.0 |
I'm pretty sure this behavior is a bug if it's true.
comment:3 by , 16 years ago
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 by , 16 years ago
| Severity: | None → Blocking |
|---|
comment:5 by , 16 years ago
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 by , 16 years ago
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 by , 16 years ago
| Severity: | Blocking → None |
|---|
comment:8 by , 16 years ago
| Milestone: | → 3.3.1.6 |
|---|---|
| Owner: | set to |
| Resolution: | → Fixed |
| Status: | new → closed |
Fixed by revision [5412] in version: 3.3.1.6

Automatic ticket cleanup.