Jump to content

scope of controlID


DrJB
 Share

Recommended Posts

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

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

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