Jump to content

Does anyone know how to set the Automation Index in WinForms


zenocon
 Share

Recommended Posts

I'm building a fake WinForms GUI that I'm using to test.  In one instance, it has a panel with a number of text elements.  I have the inspect.exe output of the real target UI that I'm trying to automate, but I'm trying to build a fake one now that emulates it so I can more easily test.

The problem is the order of the text elements in the pane is different, and I'm having a helluva time trying to figure out how to set the order -- if that's even possible.  The WinForms TabIndex property doesn't do it.  There is no Index property on it otherwise.  I'm worried it may not even be possible, so I figured I'd ask here.

Thank in advance

Link to comment
Share on other sites

Hi junkew -- Tab Index does not affect Automation Index.  I indicated that in my first post above.  The only thing that affects it, as far as I can tell, is the order you add child components to a parent.  

Edited by zenocon
Link to comment
Share on other sites

Not sure if we talk about the same but it seems possible when you read the instructions

Those numbers are the order that your controls will be hit when pressing the 'Tab' key. When in View Tab Order mode, you can click on the controls in the order that you want them to be hit. That will re-order them. You'll notice that the numbers start changing as you click

In my visual studio 2015 community edition and vs 2013 premium I just can choose menu view, taborder and then change the taborder

 

Link to comment
Share on other sites

zenocon, If you by the Automation Index means the index in the Automation element array as returned by eg. the FindAll method when this method is executed on a container control (window, group, pane) containing a set of similar controls, then you cannot set this index. And you don't have to set the index.

The important thing is that the controls always have the same position in the element array. If you execute FindAll on your fake GUI and on your real GUI and figures out that control number 3 in the fake GUI matches number 7 in the real GUI, then number 3 will always match number 7. You can simply hardcode these numbers in your script.

The index in the element array sometimes matches the tab order and sometimes not.

Link to comment
Share on other sites

In Visual Studio, there is a Document View which shows all the UI elements.  By switching to that view it shows you the parent/child hierarchy of all the elements, and it allows you to drag-n-drop elements in whatever order or hierarchy you want.  Once I figured this out, I was able to re-organize my fake UI to match the output of my inspect.exe results.

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

×
×
  • Create New...