public static WindowInfo FindWindowContains(string partOfTitle, bool includeInvisible = false) { List <WindowInfo> windows = EnumOpenWindows.GetOpenWindows(includeInvisible); WindowInfo window = windows.FirstOrDefault(app => app.Title.Contains(partOfTitle)); return(window); }
public static List <AppInfo> GetAppsWithUI() { List <AppInfo> apps = new List <AppInfo>(); apps.AddRange(EnumOpenWindows.GetOpenWindows().Select(w => new AppInfo(w))); apps.Sort((a1, a2) => string.Compare(a1.ProcessName, a2.ProcessName, true)); apps.Insert(0, AppInfo.GetEmptyAppInfo()); //Process[] processes = Process.GetProcesses(); //List<Process> pp = processes.Where(p => !string.IsNullOrEmpty(p.MainWindowTitle)).ToList(); //pp = processes.Where(p => p.MainWindowHandle != IntPtr.Zero).ToList(); //foreach (Process p in pp) // apps.Add(new AppInfo(p)); return(apps); //new ObservableCollection<AppInfo>(apps); }