question

SemyonKleinerman-4300 avatar image
0 Votes"
SemyonKleinerman-4300 asked BBarathvaj-1787 commented

UI Automation - AutomationElement.FromPoint returns element's container

I am trying to capture a toolbar in Microsoft Teams using C# AutomationElement.FromPoint function.
For some reason this function returns the whole Teams window element and not the toolbar. But....
Once I open Inspect64.exe and capture this toolbar, my AutomationElement.FromPoint starts working properly as well!!

The question is what Inspector does what I didn't?

dotnet-csharpdotnet-standard
· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@SemyonKleinerman-0643
Could you please show some code?
Is Inspect64.exe a three-party application? It should have nothing to do with the current application. Why does it affect the current application?
Could you please show some steps to allow us to recreate your problem?

0 Votes 0 ·

First of all, Inspect is a Microsoft application, it should be a part of Microsoft SDK, here the explanation:
https://docs.microsoft.com/en-us/windows/win32/winauto/inspect-objects

My flow is simple:
1. Open Microsoft Teams
2. Try to get a mouse hovered UI Automation element

I just call AutomationElement.FromPoint(new System.Windows.Point(X, Y)) while X and Y are current mouse position.
This function always returns a whole container (main window) until I apply Inspector on this application.
To reproduce an issue again I have to restart the machine.
I assume Inspector is calling for some low level function that causes accessibility to wake up





0 Votes 0 ·

@SemyonKleinerman-4300
I reproduced this problem, but I haven't found the reason for this occurrence and the available solution for the time being. This is really a strange phenomenon.
I may need some time to investigate this matter, and I will reply to you as soon as possible.

1 Vote 1 ·
Show more comments

0 Answers