zfisherdrums

[SOLVED-SORTA]Need help with Control description syntax

13 posts in this topic

#1 ·  Posted (edited)

I've come across an app where I believe I am forced to ID the control using the "X \ Y \ W \ H" property. In the help files, it reads:

X \ Y \ W \ H - The position and size of a control.

However, I don't see an example in there nor do I find one on the forum. Does anyone have an example of how to use this in the description?

EDIT: I should add that I'm attempting to do this using AutoItX3.dll

Much obliged,

Zach...

Edited by zfisherdrums

Share this post


Link to post
Share on other sites



I don't know about others, but I don't understand...

Let's see:

You are trying to automate some app and the only way you think/know you can do that is identify a control (button?) by providing it's x and y coordinates, and it's width and height?

Sounds unreal that you have to id something by providing its W and H..

What about the WindowInformationTool?


My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hello, Triblade.

Control ID is not unique in the AUT; other controls higher in the tree use the same resource ID ( yuck). Also, the index position changes dynamically based on input criteria. For example, if app is in state A, control ClassNameNN is ComboBox11. If it is in state B, then the ClassNameNN is ComboBox23.

Because the control is anchored to the top and left boundaries of the parent, I should be able to obtain a consistent handle if I can describe the control by x/y/w/h coordinates. I'm trying to do this all inline without helper functions becoming involved.

I know exactly where the control is and what dimensions it has, but my interpretation of the help file is that I should be able to provide those to AutoItX and move on with life. I understand that the control descriptions are not documented in the AutoItX help, but I believe the same capability exists. From the help file:

A special description can be used as the controlID parameter used in most of the Control...() functions . This description can be used to identify a control by the following properties:

ID - The internal control ID. The Control ID is the internal numeric identifier that windows gives to each control. It is generally the best method of identifying controls. In addition to the AutoIt Window Info Tool, other applications such as screenreaders for the blind and Microsoft tools/APIs may allow you to get this Control ID

TEXT - The text on a control, for example "&Next" on a button

CLASS - The internal control classname such as "Edit" or "Button"

CLASSNN - The ClassnameNN value as used in previous versions of AutoIt, such as "Edit1"

REGEXPCLASS - Control classname using a regular expression

X \ Y \ W \ H - The position and size of a control.

INSTANCE - The 1-based instance when all given properties match

Any thoughts? Edited by zfisherdrums

Share this post


Link to post
Share on other sites

I can only assume that it is literally used as number slash number slash number slash number. Like 3\3\40\21.

Share this post


Link to post
Share on other sites

I can only assume that it is literally used as number slash number slash number slash number. Like 3\3\40\21.

Hadn't tried that one either, but no dice. Here's what I tried so far:

WinActivate( "Calculator" )
$res = ControlClick( "[ACTIVE]", "", "[X\Y\W\H:93,138,36,29]" )
ConsoleWrite( $res & @CRLF)
$res = ControlClick( "[ACTIVE]", "", "[X \ Y \ W \ H:93,138,36,29]" )
ConsoleWrite( $res & @CRLF)
$res = ControlClick( "[ACTIVE]", "", "[X \ Y \ W \ H:93, 138, 36, 29]" )
ConsoleWrite( $res & @CRLF)
$res = ControlClick( "[ACTIVE]", "", "[X:93;Y:138;W:36;H:29]" )
ConsoleWrite( $res & @CRLF)
$res = ControlClick( "[ACTIVE]", "", "[93,138,36,29]" )
ConsoleWrite( $res & @CRLF)
$res = ControlClick( "[ACTIVE]", "", "[x\y\w\h:93,138,36,29]" )
ConsoleWrite( $res & @CRLF)
$res = ControlClick( "[ACTIVE]", "", "[x \ y \ w \ h:93,138,36,29]" )
ConsoleWrite( $res & @CRLF)
$res = ControlClick( "[ACTIVE]", "", "[x \ y \ w \ h:93, 138, 36, 29]" )
ConsoleWrite( $res & @CRLF)
$res = ControlClick( "[ACTIVE]", "", "[x:93;y:138;w:36;h:29]" )

All return '0'. Has anyone ever used this property? Am I crazy?

Share this post


Link to post
Share on other sites

You didn't try anything like what I posted.

$res = ControlClick("[ACTIVE]", "", "[93\138\36\29]")

Like I said, number slash number slash number slash number. I don't know for sure, but that makes the most sense to me.

Share this post


Link to post
Share on other sites

You didn't try anything like what I posted.

$res = ControlClick("[ACTIVE]", "", "[93\138\36\29]")

Like I said, number slash number slash number slash number. I don't know for sure, but that makes the most sense to me.

Thank you for your suggestion. I tried that exact expression earlier today and to no avail. I even tried reversing the slashes in all the examples above ( including yours ). No love.

Share this post


Link to post
Share on other sites

Try

$res = ControlClick("[ACTIVE]", "", "[X:93 \Y:138 \W:36 \H:29]")

Share this post


Link to post
Share on other sites

Try

$res = ControlClick("[ACTIVE]", "", "[X:93 \Y:138 \W:36 \H:29]")
Thank you. Now we're getting somewhere. Here's the odd thing: The coordinates provided were for the "2" button on a standard-view Calculator. However, the "8" button is being pressed. Any idea how the coordinates are being interpreted?

Zach...

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Thank you. Now we're getting somewhere. Here's the odd thing: The coordinates provided were for the "2" button on a standard-view Calculator. However, the "8" button is being pressed. Any idea how the coordinates are being interpreted?

Zach...

Try, try, again.

$res = ControlClick("[ACTIVE]", "", "[X:93\; Y:138\; W:36\: H:29\]")

Edit ................................................................................................^...

.. Colan works ?

At this moment, this $res = ControlClick("[ACTIVE]", "", "[X:93\; Y:138\]") is also working for me.

Edited by Malkey

Share this post


Link to post
Share on other sites

Thank you. Now we're getting somewhere. Here's the odd thing: The coordinates provided were for the "2" button on a standard-view Calculator. However, the "8" button is being pressed. Any idea how the coordinates are being interpreted?

Zach...

Apologies, I tried that way on an app I use regularly and it worked fine, but I didnt try it on the Windows calculator.

Try, try, again.

$res = ControlClick("[ACTIVE]", "", "[X:93\; Y:138\; W:36\: H:29\]")

Edit ................................................................................................^...

.. Colan works ?

Yep a semicolon between X \ Y fixes it. Strange thing is a semicolon between W \ H breaks it again for me.

Im using Vista 32 bit & AutoIt 3.2.12.0

Share this post


Link to post
Share on other sites

I'm not sure exactly. I was only guessing on the syntax to begin with.

Share this post


Link to post
Share on other sites

I'm not sure exactly. I was only guessing on the syntax to begin with.

Richard,

Hey, your guess was as good as any. I can say for certain that the "working" example provided was fairly non-intuitive; especially the need for a colon between width and height. Perhaps that is a bug?

I say "working" because the behavior of referencing control IDs in this fashion appears to be inconsistent. What worked in calculator did not work in the app under test. Fortunately, I discovered that the controls in question are always the last ones rendered regardles of application state. It would be real neat if AutoIt allowed syntax like this:

ControlClick( "[ACTIVE]", "", "[CLASS:ComboBox;INSTANCE:-4]" )

The above statement would click on the ComboBox instance that is 4th from the last instance. Maybe I'll find the appropriate place to suggest it. Until then, I think the help file should be updated to help out for this feature. That's also a post for another part of the forum, I suppose.

Thanks everyone for your help! If you have any other suggestions/examples on this feature, send 'em my way.

Zach...

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