DrJB Posted November 30, 2007 Share Posted November 30, 2007 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 More sharing options...
weaponx Posted November 30, 2007 Share Posted November 30, 2007 No, you cannot count on it to stay consistent. Instead rely on class name and instance number. Link to comment Share on other sites More sharing options...
DrJB Posted November 30, 2007 Author Share Posted November 30, 2007 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 More sharing options...
weaponx Posted November 30, 2007 Share Posted November 30, 2007 What kind of consistency are you seeing with the controlids now? Are they staying the same after opening and closing the app? Link to comment Share on other sites More sharing options...
DrJB Posted November 30, 2007 Author Share Posted November 30, 2007 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. Link to comment Share on other sites More sharing options...
Klaatu Posted November 30, 2007 Share Posted November 30, 2007 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 IDI 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 More sharing options...
weaponx Posted November 30, 2007 Share Posted November 30, 2007 The controlid can change. Here is one example:http://www.autoitscript.com/forum/index.ph...rolid++changinghttp://www.autoitscript.com/forum/index.ph...rolid++changingI think it's considered the best method because its the easiest syntax to use the controlid directly. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now