I am trying to find all desktop windows using .NET UIAutomation OR White framework. I tried :
1.)
AutomationElement rootElement = AutomationElement.RootElement;
var winCollection = rootElement.FindAll(TreeScope.Subtree, Condition.TrueCondition);
2.)
Desktop.Instance.Windows();
Both throw ArgumentException. Please let me know if there are other ways to do this...
UPDATE/ANSWER: Desktop.Instance.Windows(); works fine except that it throws exception while debugging the code using VS2010.