Sign in to follow this  
Followers 0
louislahure

How to uniquely identify multiple controls in Window other than class/id.

2 posts in this topic

#1 ·  Posted (edited)

I'm new to AutoIt but have put in an embarrassingly large amount of time learning some of the very basics.  This one has me stuck and I'm hoping someone's 5 minutes could save me a couple hours, if not more.  I'll try to put this concisely: 

There is a window with multiple controls, anywhere from 3 to 7, and they can be arranged in any order.  My goal is a simple ControlFocus, etc, to focus and navigate menus within them in a specific order but it needs to work if they were arranged.*  Referring to the classnn as "Edit1" and "Edit2", etc, however, doesn't work because the control with Edit1 becomes Edit2 if rearranged and the order is broken.  I tried referring to the ID, as 90% of them are unique within all the optional controls, but even then a couple controls share a similar id.  Since the classnn can change and these controls share the same ID, how can I uniquely (and easily) identify them (in a way that survives them being rearranged).  

My last attempt was to ControlGetPos because the width/height are unique but not only does it return a blank but also I don't know how to only check for those.  The text in the control isn't reliable, also, as that changes here and there. The only last thing I see as unique in the Window Info tool is the style, but how can I tie that in with a ControlFocus, etc?

I appreciate the help!  Looking through most of these forums posts and google results shows me to lack a lot of understanding of AutoIt so maybe there is a simple command I've overlooked in tutorials, etc.  

Thanks again. 

Edited by louislahure

Share this post


Link to post
Share on other sites



I was tired and it's a little confusing. 

There are multiple controls in a window and they can be rearranged.  When rearranged, different controls receive different Class/Instance, so I can't refer to those without referring to a different control.  If I have A B C D E and they are Edit1, Edit2, Edit3, etc, then when those controls are rearranged (B D A C E) then B becomes Edit1 rather than A, D is Edit2, etc. 

I tried referring to the IDs for each control but two or three of them share the same ID, so for those 2 or 3 I can't refer to either the Class/Instance or the ID and my script does not work if any of them are rearranged.  So I need a new variable that remains constant for each control that Auto It can find that is not a class/instance or ID.  

I tried https://www.autoitscript.com/autoit3/docs/intro/controls.htm to find a constant variable but TEXT wont' work, there is no NAME, I haven't understood yet REGEXPCLASS and XYWH could work if I could somehow do a ControlSetFocus for only the width and the height, which is unique, leaving the coordinates -- which change when rearranged -- as unknowns or unimportant data. 

Hm--hope that clarifies things; I'm still tired but mostly thinking aloud. Thanks!

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