Modify

#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 Valik)

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 TicketCleanup, on May 29, 2012 at 3:00:01 AM

Version: 3.3.8.1

Automatic ticket cleanup.

comment:2 by Valik, on May 29, 2012 at 3:35:28 AM

Description: modified (diff)

comment:3 by trancexx, on Jun 4, 2012 at 9:44:33 AM

The ting is that these controls doesn'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".

Version 0, edited on Jun 4, 2012 at 9:44:33 AM by trancexx (next)

in reply to:  3 comment:4 by junkew@…, on Jun 24, 2012 at 12:31:46 PM

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 trancexx, on Aug 19, 2012 at 9:37:06 PM

Resolution: Rejected
Status: newclosed

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.

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.