I am trying to get a control at a specific screen coordinate which I have given. Now I want to know which control would receive a mouse-click. (The control is in another application in an UI Automation scenario.)
Also, let me say, that Control, Windows Handle and AutomationElement are all the same to me, since they are more or less easily convertible into one another (apart from maybe a Control which I think does not work in a different process).
There are the obvious functions like WindowFromPoint and AutomationElement.FromPoint, but both fail, returning some element that seems to be (invisibly) custom drawn on top. Still, I know that the mouse clicks go to the control I desire. So.. is there a way to find out where the mouse clicks are really going? Maybe alternatively to find out whether an element passes mouse-clicks through?
Many thanks
Andreas
Since there are no answers (or am I too impatient?), there is.. not a solution but rather a workaround I have found.
Actually, what I would have wanted is a deep search that is parameterizable (which unfortunately does not exist, though I suppose you could do it recursively yourself).
So.. the workaround is: I make the windows I don’t want invisible.
Strangely and interestingly enough, this is easily doable from outside your application, simply call the ShowWindow ( http://www.pinvoke.net/default.aspx/user32/ShowWindow.html ) function and hide the window that you don’t want to take into account. You could reset it later to its original state if you don’t want to change the target application.
Anybody who has a better solution: by all means, please tell me!