Jump to content

Controls with the same ID and changing Instance


Recommended Posts

Dear AutoIt forum members,

I need help in automating a software GUI in a robust way. It is an image acquisition software.

I need to push a 'Start' button, in a tab that can (or cannot) be shown in a subwindow of the GUI. Also the subwindow can or cannot be visible, but all controls would be anyway active and generally accessible, but this Start button is giving me a lot of trouble. All controls are always functional, even when hidden. See the GUI portion below:

 

window.png

 

  • I cannot push it by Coordinate clicking, as the location or visibility of its tab depends on what the user did before the automation starts, so it is not a robust method.
  • I cannot push in by calling "[TEXT:Start]" as it simply does not work. I do not know why, but AutoIt does not do anything in response to this. There are apparently no other controls with 'Start' text in the GUI
  • I cannot push it by ID, as there is another button with THE SAME ID in another tab! If I call the ID, the other button gets pushed, maybe because it has a lower Instance number.
  • I cannot push it by Instance number, as the Instance numbers of controls change wildly from one time to the other that the software is launched, so they are not reliable at all.

Please, help me, as I think I run out of the options I knew about. Find below the Window Info for this control.

 

ControlInfo.png

 

Many thanks and best regards,

g.

 

Link to comment
Share on other sites

32 minutes ago, Giampaolo said:

I cannot push it by ID, as there is another button with THE SAME ID in another tab! If I call the ID, the other button gets pushed, maybe because it has a lower Instance number.

If it has a different instance number, how is it the same ID?

Use its instance number with ControlClick function.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Dear JohnOne, 

thank you for yours.

What you suggest works as long as the software is open, but when I close it and reopen it, the Instance numbers of the controls (most of them) will have changed. I have seen that this happens when the GUI is programmed in a dynamic way, or something like that (several threads on this in the forum).

The IDs of the controls stay the same anytime I reopen the software, so this is what I used for most of the controls. But for some reason, at least three controls in the GUI (across different tabs) have the same IDs, in pairs (two I can call by name, it seems. This "Start" I cannot). 

best regards,

g.

Link to comment
Share on other sites

It's rather unusual that the instance number should change between starts.

You have a number of options.

1. Try UIAtomation, which you will find pinned in example scripts section.

2. Enumerate all controls of window when your script starts, iterate through them, checking for button class, with correct text, size and position. You will find examples of how to do that, too, in example scripts section.

I'd go for option 1 if it were me.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Thank you JohnOne. 

I will try something. Possibly, UIAtomation is beyond my time and possibilities. Maybe I could try to somehow find the handle for the control I need even if it sometimes changes instance and has the same ID. Somehow it should be possible to find the handle through its text, even though so far attempts have been irreproducible, to say the least.

best regards,

g.

 

Link to comment
Share on other sites

Thank you once more, JohnOne. I actually got a hint from a previous thread you participated in.

I think I got around the problem by searching the control handle by the size of the controls as it happens in my GUI that the controls with the same ID and changing instance number have a different size (luckily). This was especially lucky for two ComboBoxes as same ID, changing instance and no control text left me with two virtually identical controls I could not distinguish otherwise. 

best regards,

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