public void AddProcessesToWatch(IEnumerable <Process> procs) { foreach (var proc in procs) { ProcessWatcher.Add(proc); } }
public static bool EnumWindowsCallBack(int Hwnd, ProcessWatcher processWatcher) { if (!IsWindowVisible(Hwnd)) return true; if (IsAltTabWindow(Hwnd)) { try { StringBuilder windowClass = new StringBuilder(256); UnmanagedCode.GetClassName(Hwnd, windowClass, windowClass.Capacity); StringBuilder windowText = new StringBuilder(256); UnmanagedCode.GetWindowText(Hwnd, windowText, windowText.Capacity); IntPtr pid = (IntPtr)0; GetWindowThreadProcessId(Hwnd, ref pid); processWatcher.Add(pid.ToInt32(), Hwnd, windowClass.ToString(), windowText.ToString()); } catch //(Exception ex) { //MessageBox.Show(ex.Message); } } return true; }