isma08

GET TEXT FROM A BUTTON

11 posts in this topic

HI, I cant get the text of a button, I'm testing with the "9" button windows calculator but the result is ""

 

$codigo = ControlGetText(WinGetTitle("[CLASS:CalcFrame]"), "", "[CLASS:Button; INSTANCE:14]")
MsgBox(0,"CODIGO",$codigo)

Share this post


Link to post
Share on other sites



Hi, isma08, welcome to the forum. This works just fine for me, why the nested WinGetTitle when you have the Class already?

$text = ControlGetText("[CLASS:CalcFrame]", "", "Button14")
MsgBox(0, "", $text)

 


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

Hi, Thx. 

I have many contributions I can make to the forum, and I will soon, but I still get the button text :(

any other ideas?

test1.jpg

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

that's the problem, the info-tool does not show me the text, but not if there is any way in programming.

 

>>>> Window <<<<
Title:  Calculadora
Class:  CalcFrame
Position:   1772, 234
Size:   228, 322
Style:  0x14CA0000
ExStyle:    0x00000100
Handle: 0x00060700

>>>> Control <<<<
Class:  Button
Instance:   14
ClassnameNN:    Button14
Name:   
Advanced (Class):   [CLASS:Button; INSTANCE:14]
ID: 139
Text:   
Position:   89, 129
Size:   34, 27
ControlClick Coords:    18, 14
Style:  0x50000000
ExStyle:    0x00000004
Handle: 0x000207CE

>>>> Mouse <<<<
Position:   1887, 427
Cursor ID:  0
Color:  0x6A395B

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
0


>>>> Hidden Text <<<<

 

Edited by isma08

Share this post


Link to post
Share on other sites

Notice window info tool cannot even get the text.

The code is fine 

$text = ControlClick("[CLASS:CalcFrame]", "", "[CLASS:Button; INSTANCE:14]")

It's just not giving up its text, I've no idea why, except it's not a win32 standard control.

Just the way it is sometimes.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Calculator is given as an example and it has GetValue as a function, not sure it will return the value you need, but its worth a look.

Share this post


Link to post
Share on other sites

:(  any idea how to get the text.?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

The code below only works because the control id's for the calculator buttons end in the number corresponding to the button...   so it appears for me at least.

#include <WinAPI.au3>

$hWndButton = ControlGetHandle("[CLASS:CalcFrame]", "", "Button14")
$strButtonCtrlID = _WinAPI_GetDlgCtrlID($hWndButton)

MsgBox(0,"", StringRight($strButtonCtrlID, 1))

Most of the time ControlGetText will work as you expect, however, in this specific case the text property is blank so there is no text to get.

Hope this helps you out somehow.

Edited by MaxG
Fixed spelling and removed some speculation.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

My System is windows xp

so i try with xp calc

it worked

$a = ControlGetText("[CLASS:SciCalc]", "","Button14")
MsgBox(0, "", $a)

 

Edited by TLM

Share this post


Link to post
Share on other sites

Calc.exe ( and some other) since windows vista Draw the text. if you do not want to use IUIAutomation. You simple can create an array to check if Button instance=5 I'm over (number 1) etc...

 

Saludos

Share this post


Link to post
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