//Script.NET examples
//(c)2007-2009, Protsyk Petro, http://www.protsyk.com

//Initialize UIAutomation Libraries
u0 = Assembly.Load('WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35');
u1 = Assembly.Load('UIAutomationClient, version=3.0.0.0, Culture=neutral , PublicKeyToken=31bf3856ad364e35');
u2 = Assembly.Load('UIAutomationClientSideProviders, version=3.0.0.0, Culture=neutral , PublicKeyToken=31bf3856ad364e35');
u3 = Assembly.Load('UIAutomationProvider, version=3.0.0.0, Culture=neutral , PublicKeyToken=31bf3856ad364e35');
u4 = Assembly.Load('UIAutomationTypes, version=3.0.0.0, Culture=neutral , PublicKeyToken=31bf3856ad364e35');

//Initalize Variables
TrueCondition = System.Windows.Automation.Condition.TrueCondition;
Children = System.Windows.Automation.TreeScope.Children;

function FindChilds( RootElement, Recursively )
{
  col = RootElement.FindAll(Children, TrueCondition);
  foreach (el in col)
  {                     
     if (el.Current.Name != '')
     Console.WriteLine(el.Current.Name);
  
     if (Recursively) FindChilds(el, Recursively);
  }
}

mouse_point = new System.Windows.Point(Cursor.Position.X, Cursor.Position.Y);
currentElement = AutomationElement.FromPoint(mouse_point);

FindChilds(AutomationElement.RootElement, true);

