Quantcast
Channel: Windows Desktop Development for Accessibility and Automation forum
Viewing all articles
Browse latest Browse all 585

AutomationElement.FromPoint method retrieves wrong AutomationElement in some cases

$
0
0

I am working on an application where I need to know if the mouse cursor is over the maximize button. When I use AutomationElement.FromPoint method to retrieve the AutomationElement, I retrieve the wrong element in some cases.

I wrote a simple console application based on the MSDN example code:

while(true)
  {
  System.Windows.Point point = new System.Windows.Point(Cursor.Position.X, Cursor.Position.Y);

  AutomationElement element = AutomationElement.FromPoint(point);

  if(element != null)
  {
    Console.WriteLine("Element at position " + point + " is '" + element.Current.Name + "'");  }  Thread.Sleep(1000);
}

The problem I encounter is that I retrieve the minimize button AutomationElement when the mouse pointer is over the first third part of the maximize button of Notepad on Windows 10. When the mouse pointer is over the first third part of the close button the retrieved element is the maximize button. Running Windows 8.1 I get similar behaviour on the close button of Notepad.

I would like to know what is going wrong in my approach.

Thanks,

Sander

Viewing all articles
Browse latest Browse all 585

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>