I am looking for a method to "click" a toolbar button in another application using the UIAutomation namespace. The other application is not written by me and I don't have access to the source.
I found the parent window using:
AutomationElement _automationElement = AutomationElement.RootElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "Other App"));
I found the toolbar element using:
AutomationElement _toolbarElement = _automationElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "ToolBar1"));
I've tried to navigate further into the toolbar element for decendents and children and they all returned null. Is there a way to access the individual buttons contained within the toolbar?
I'm working on a similar project, in my case I used this
to find all visible buttons and then put in a variable the need one, however I'm still seeking an adequate method to do the click. At this link there's a method but until now I didn't found the right
Mouseclass to use. If you can instead, please share.EDIT: In the end I preferred another approach that worked pretty well
The only thing I had to check is if the button have
IsInvokePatternAvailable: truewith Inspect.exe (part of Windows SDK)