Jump to content

ControlGetText using position


Recommended Posts

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?

Link to comment
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.

Link to comment
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]

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
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\]")
Link to comment
Share on other sites

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
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...