public static IEnumerable<IntPtr> EnumAllWindows()
{
// Create the list of windows
var list = new List<IntPtr>();
// For each top-level windows
foreach (var topWindow in EnumTopLevelWindows())
{
// Add this window to the list
list.Add(topWindow);
// Enumerate and add the children of this window
list.AddRange(EnumChildWindows(topWindow));
}
// Return the list of windows
return list;
}