Sign in to follow this  
Followers 0
DrJB

scope of controlID

7 posts in this topic

Does a controlID change between instances of an application?

For example:

Lets say I run an application 'foo' and get the control ID for a ListBox in foo. The next time I run foo, will the control ID have changed for that ListBox? Can I count on that ID to be the same across machines etc... ?

Share this post


Link to post
Share on other sites



No, you cannot count on it to stay consistent. Instead rely on class name and instance number.

Share this post


Link to post
Share on other sites

No, you cannot count on it to stay consistent. Instead rely on class name and instance number.

I can't rely on instance number. It does not remain constant.

I'm automating an MDI app. The instance numbers in the main app change as I open and close documents. So in the main frame, I have a few listboxes. If I open a document, the instance numbers change. Depending on the document I open, they change to different instance numbers. So one control may be ListBox5 on app startup, but the same control becomes ListBox10 or ListBox18 after I open a document.

Share this post


Link to post
Share on other sites

What kind of consistency are you seeing with the controlids now? Are they staying the same after opening and closing the app?

Share this post


Link to post
Share on other sites

Thanks for the quick replies :-)

If I kill and relaunch a few times, it stays the same. I'm not sure about after opening/closing other apps or restarting the machine.

Share this post


Link to post
Share on other sites

No, you cannot count on it to stay consistent. Instead rely on class name and instance number.

If that's true, I wonder why AutoIt's help file says this about the ID:

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

I almost never use the control ID myself, instead using class and instance or classnn (same thing, basically), but I was always curious why the help file says ID is the best.

My Projects:DebugIt - Debug your AutoIt scripts with DebugIt!

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