Jump to content

Inconsistencies in ControlGetText from some windows


Recommended Posts

Hello all! I have had some issues reading text from different types of windows, occasionally, specifically with controlgettext. 

**Before I begin, I know there are better ways to do what I attempt in the example below. That's not the point of this post. The point is my issues with controlgettext. 

I am about to cite an example with an application you may be familiar with called SpeedFan (v4.52). My problem is not specific to speedfan, it is simply the most recent and easily reproducible example I can think of. 

So, the goal of the script below is to get a string of text containing the current fan RPMs from the highlighted control in the screenshot below (see "speedfan_control_details.png").

speedfan_control_details.png

Now, here's a simple script for grabbing the window handle and reading the text from that control: 

$wintitle = "SpeedFan 4.52"
$controlID = "197934" ;will be reformatted as "[ID:######]"

$hwnd = wingethandle($wintitle)
if @error<>0 then
    msgbox(0, "WinGetHandle", "FAILURE. @error="&@error)
    Exit
EndIf

$text = ControlGetText($hwnd, "", "[ID:"&$controlID&"]")
if @error=1 then
    msgbox(0, "ControlGetText", "FAILURE. @error="&@error) ;failure returns "" and @error=1
    Exit
EndIf

msgbox (0, "ControlGetText", "SUCCESS. @error="&@error &@CRLF& "$text="&$text) ;success returns string and @error=0

You'll see that the ControlGetText operation runs without error, however it does not capture any text from the control. If you explore the other controls in this one window, you'll find mixed results across the board. Neither the temps nor voltages can be read, while the log field and some other elements can be read. Even when you read the text from the whole window, those elements are not included in the visible nor hidden texts. 

 

I have run into this issue many times in the past- inconsistencies in the ability of autoit to interact with certain controls. What is it which makes this text different than any other readable texts? Is there an alternate method of reading the text in the window/control which could work? Any and all info to help me solve this mystery and satisfy my curiosity would be greatly appreciated. 

Thanks :) -Rob C

PS: Running Autoit v3.3.14.2 on Win7 Ultimate x64

Link to comment
Share on other sites

I don't think this will be the case in this instance, but sometimes control groups are selected above the actual controls within the groups by the spy tool.  Try using my signature function to get all controls within a window, and see if you have any luck.  The function expects a handle from wingethandle

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...