Using UIAutomation on windows Forms, I'm trying to retrieve any control under mouse on a specific form. The goal is to work on controls of an app, retrieving and acting on them.
The problem I'm facing since so many times is that I can't find a toolstripbutton. Everytime I'm getting a pane (not parent nor child of the toolstripbutton I want, but parent's sibling).
This is the toolstripbutton I want to retrieve : .
The same control but in Inspect.exe (highlighted: the control I'm getting) :
I though that it was because of z order of the controls, then I tried using sibling controls, for controls where their bounds contains the mouse (for getting all controls under the cursor anyway their z order). That fails because the toolstripbutton isn't retrieved.
I currently use UIAutomation and not CodedUI, because I need to run a custom program which retrieve controls and executes automatic tests on a specific server, but I actually have the Visual Studio Enterprise 2017 licence installed on my machine, but a second licence (for the server) and a third licence for a colleague for work with me on it would be a bit expensive.
Remembering that the programs have to retrieve dynamically the controls under the mouse, may someone gives me any idea which can help me to investigate deeper ?
Thanks & Greetings
Method used:
var aimed = AutomationElement.FromPoint(new System.Windows.Point(Cursor.Position.X, Cursor.Position.Y));