Sign in to follow this  
Followers 0
IQ9003

ControlGetText using position

9 posts in this topic

I'm having trouble using the ControlGetText function.

In the old AutoITV3 (with the Au3Lib) I used this function:

_ControlGetControlText($MAIN_WINDOW_TITLE, "", $RELATIE_LABEL_RELNR_X, $RELATIE_LABEL_RELNR_Y)

Now I'm trying to translate this to the newer version of AutoIT and I use this:

ControlGetText($MAIN_WINDOW_TITLE, "", "[X:8; Y:133; W:119; H:18]")

But this doesn't work, it doesn't find the controls value (it's an editbox : Edit1). The program has different pages, and the editboxname isn't always the same (The position is always the same).

The following code does work, but because Edit1 can change to Edit2 I need to get the text from the position:

ControlGetText($MAIN_WINDOW_TITLE,"","Edit1")

What am I doing wrong? (and how can I do it better?

Share this post


Link to post
Share on other sites



Edit1 is the classname right? I think what you need is the control id. That should always be the same. You can get this using the au3info tool.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

Hello,

The control ID doesn't work for me. The application i'm using has various screens (100+) in wich the editbox that I want to read is always on the same coords, but doesn't have the same controlID.

The old au3lib function gives me result, but the new function gives me an errorcode1.

(The au3info also shows the right info)

Edit1 is the classname right? I think what you need is the control id. That should always be the same. You can get this using the au3info tool.

Share this post


Link to post
Share on other sites

Post the info given by the AutoIt Control window.

I assume you mean the control ID changes each time you close and start the app for the same control?


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

First you need to use Autoit Window Info to test if you can scan and get the text of that window. In some game, for ex, they have protection, you can scan the Edit control ID, but they don't let you get the text or modify the text inside.

If ControlGetText($MAIN_WINDOW_TITLE,"","Edit1")='' Then
   $text = ControlGetText($MAIN_WINDOW_TITLE,"","Edit2")
Edited by trung0407

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Here's some more info:

The program we're using enables users to make custom screens inside the application. When a new screen is made and an editbox is added it gets edit1 as an id, the second gets edit2. Therefore I need to use the coordinates.

While the Function in the old AutoIt works in the newer it doesn't.

Here's the info I got with the AU3Info-tool:

(Two different screens but the editbox is used for the same info)

>>>> Window <<<<

Title: Uitwijk

Class: AcucobolWClass

Position: -2

Size: 888, 594

Style: 0x14CF0000

ExStyle: 0x00000100

Handle: 0x002403AE

>>>> Control <<<<

Class: Edit

Instance: 5

ClassnameNN: Edit5

Advanced (Class): [CLASS:Edit; INSTANCE:5]

ID: 2208

Text:

Position: 448, 238

Size: 147, 18

ControlClick Coords: 28, 0

Style: 0x50000080

ExStyle: 0x00000004

Handle: 0x001A0680

>>>> Mouse <<<<

Position: 479, 279

Cursor ID: 0

Color: 0x000000

>>>> StatusBar <<<<

>>>> Window <<<<

Title: Uitwijk

Class: AcucobolWClass

Position: -2

Size: 888, 594

Style: 0x14CF0000

ExStyle: 0x00000100

Handle: 0x002403AE

>>>> Control <<<<

Class: Edit

Instance: 5

ClassnameNN: Edit5

Advanced (Class): [CLASS:Edit; INSTANCE:5]

ID: 2208

Text:

Position: 448, 238

Size: 147, 18

ControlClick Coords: 28, 0

Style: 0x50000080

ExStyle: 0x00000004

Handle: 0x001A0680

>>>> Mouse <<<<

Position: 479, 279

Cursor ID: 0

Color: 0x000000

>>>> StatusBar <<<<

Edited by IQ9003

Share this post


Link to post
Share on other sites

It says Edit5, not edit1 or 2...

Share this post


Link to post
Share on other sites

I'm having trouble using the ControlGetText function.

In the old AutoITV3 (with the Au3Lib) I used this function:

_ControlGetControlText($MAIN_WINDOW_TITLE, "", $RELATIE_LABEL_RELNR_X, $RELATIE_LABEL_RELNR_Y)

Now I'm trying to translate this to the newer version of AutoIT and I use this:

ControlGetText($MAIN_WINDOW_TITLE, "", "[X:8; Y:133; W:119; H:18]")

But this doesn't work, it doesn't find the controls value (it's an editbox : Edit1). The program has different pages, and the editboxname isn't always the same (The position is always the same).

The following code does work, but because Edit1 can change to Edit2 I need to get the text from the position:

ControlGetText($MAIN_WINDOW_TITLE,"","Edit1")

What am I doing wrong? (and how can I do it better?

I have had this format work.

ControlGetText($MAIN_WINDOW_TITLE, "", "[X:8\;Y:133\]")

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Thanx,

I've tried ControlGetText($MAIN_WINDOW_TITLE, "", "[X:7\;Y:2\]") and it works.

But now I've got another problem. The code works, however i'm not able to read a static or an editbox.

Ill's start a new topic for this problem

Edited by IQ9003

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
Sign in to follow this  
Followers 0