Opened 14 years ago
Closed 14 years ago
#2208 closed Feature Request (Rejected)
ControlGetText not working on calculator
| Reported by: | anonymous | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | Severity: | None | |
| Keywords: | Cc: |
Description (last modified by )
Win7 64 bits mode (and 32 bits mode)
Unable to get text of (static) control. Reproduced with below code on calculator.
I believe this is due to changed behaviour of WM_GETTEXT in Win Vista/7 (and as such probably not a bug) but for standardcontrols would be nice if there is a workaround to get for example the text labels of the calculator buttons.
Also AU3Info x64 and x86 hoovering over the buttons give no text value and spy++ neither.
;Calculator, make sure its started
;$calcHWND = WinGetHandle("[CLASS:SciCalc]")
$calcHWND = WinGetHandle("[REGEXPCLASS:.*Calc.*]")
if $calchwnd = "" Then
run("calc.exe")
sleep(2000)
; $calcHWND = WinGetHandle("[CLASS:SciCalc]")
$calcHWND = WinGetHandle("[REGEXPCLASS:.*Calc.*]")
EndIf
winactivate($calcHWND)
Local $hHandle = ControlGetHandle("", "", "[CLASS:Button; INSTANCE:8]")
Local $aPos = ControlGetPos("", "", $hHandle)
local $cText= controlgettext("","",$hHandle)
Local $wText = wingettext($hHandle)
Consolewrite("Window Stats:" & "Position: " & $aPos[0] & "," & $aPos[1] & @CRLF & "Size: " & $aPos[2] & "," & $aPos[3] & @CRLF)
ConsoleWrite("text:" & $cText & @crlf)
consolewrite("text2:" & $wText & @crlf)
Attachments (0)
Change History (5)
comment:1 by , 14 years ago
| Version: | 3.3.8.1 |
|---|
comment:2 by , 14 years ago
| Description: | modified (diff) |
|---|
follow-up: 4 comment:3 by , 14 years ago
The thing is that these controls don't respond to messages we send.
Alternative could be to use UI Automation API (that's not available on all systems). That works even for those controls. However, the results are sometimes different than expected. For example, the text from calc number buttons is successfully get (text from button 8 is "8") and matches the one it's printed on them, but for CE button retrieved text is "Clear Entry".
comment:4 by , 14 years ago
MSAA works on all platforms although going forward UI automation is a better choice.
Microsoft's inspect.exe 64 bits gives same result on CE button so somehow the text CE is not retrievable.
Anyway it would be an improvement to get more details by integrating ui automation on platforms that have uiautomationcore.dll installed (from Win 7 version upwards that should be the case) that at least for some controls we have more information available to act on.
comment:5 by , 14 years ago
| Resolution: | → Rejected |
|---|---|
| Status: | new → closed |
It would only confuse users more.
My opinion at this point is that ControlGetText should not return this text as it can be anything and not necessarily what's displayed on control.

Automatic ticket cleanup.