public bool IsAltTabWindow() { var name = GetName(); Interop.TITLEBARINFO ti = new Interop.TITLEBARINFO(); IntPtr hwndTry = IntPtr.Zero; IntPtr hwndWalk = IntPtr.Zero; if (!Interop.IsWindowVisible(hwnd)) { return(false); } hwndTry = Interop.GetAncestor(hwnd, Interop.GA_ROOTOWNER); while (hwndTry != hwndWalk) { hwndWalk = hwndTry; hwndTry = Interop.GetLastActivePopup(hwndWalk); if (Interop.IsWindowVisible(hwndTry)) { break; } } if (hwndWalk != hwnd) { return(false); } // the following removes some task tray programs and "Program Manager" /*ti.cbSize = (uint)Marshal.SizeOf<Interop.TITLEBARINFO>(); * Interop.GetTitleBarInfo(hwnd, ref ti); * if ((ti.rgstate[0] & Interop.STATE_SYSTEM_INVISIBLE) != 0) * return false;*/ // Tool windows should not be displayed either, these do not appear in the // task bar. if ((Interop.GetWindowLong(hwnd, Interop.GWL_EXSTYLE) & Interop.WS_EX_TOOLWINDOW) != 0) { return(false); } return(true); }
public bool IsAltTabWindow() { var name = GetName(); Interop.TITLEBARINFO ti = new Interop.TITLEBARINFO(); IntPtr hwndTry = IntPtr.Zero; IntPtr hwndWalk = IntPtr.Zero; if (!Interop.IsWindowVisible(hwnd)) return false; hwndTry = Interop.GetAncestor(hwnd, Interop.GA_ROOTOWNER); while (hwndTry != hwndWalk) { hwndWalk = hwndTry; hwndTry = Interop.GetLastActivePopup(hwndWalk); if (Interop.IsWindowVisible(hwndTry)) break; } if (hwndWalk != hwnd) return false; // the following removes some task tray programs and "Program Manager" /*ti.cbSize = (uint)Marshal.SizeOf<Interop.TITLEBARINFO>(); Interop.GetTitleBarInfo(hwnd, ref ti); if ((ti.rgstate[0] & Interop.STATE_SYSTEM_INVISIBLE) != 0) return false;*/ // Tool windows should not be displayed either, these do not appear in the // task bar. if ((Interop.GetWindowLong(hwnd, Interop.GWL_EXSTYLE) & Interop.WS_EX_TOOLWINDOW) != 0) return false; return true; }