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