Moving Mouse To Clickable Points

I'm goimng to show you how I  get  clickable coordinates for the buttons. Please take into account that if the clickable coordinate is inside a Visual Studio frame it's likely to fail. You will get the following error:

NonComVisibleBaseClass was detected,

Message: A QueryInterface call was made requesting the class interface of COM visible managed class.
 
'MS.Internal.AutomationProxies.WindowsButton'. However since this class derives from non COM visible class.
 
'MS.Internal.AutomationProxies.ProxyHwnd', the QueryInterface call will fail. This is done to prevent the non COM visible base class from being constrained by the COM versioning rules.
  1. public static Point getClickablepoint(AutomationElement button) {  
  2.     System.Windows.Point clickablePoint = new System.Windows.Point();  
  3.     button.TryGetClickablePoint(out clickablePoint);  
  4.     //Console.WriteLine(clickablePoint.X.ToString() + "," + clickablePoint.Y.ToString());  
  5.     int x = (int) clickablePoint.X;  
  6.     int y = (int) clickablePoint.Y;  
  7.     return (new Point(x, y));  
  8. }  
  9. //move mouse pointer to this position  
  10. Cursor.Position = getClickablepoint(button);