private static bool IsAppWindow(IntPtr hWnd) { if ((GetWindowLong(hWnd, (int)EnumGWLIndex.GWL_STYLE) & (int)EnumWindowsStyle.WS_SYSMENU) == 0) { return(false); } if (DllUser32.IsWindowVisible(hWnd)) { if ((GetWindowLong(hWnd, (int)EnumGWLIndex.GWL_EXSTYLE) & (int)EnumWindowsStyleEx.WS_EX_TOOLWINDOW) != 0) { return(false); } var hwndOwner = DllUser32.GetWindow(hWnd, (int)EnumGetWindowConstants.GW_OWNER); return((GetWindowLong(hwndOwner, (int)EnumGWLIndex.GWL_STYLE) & ((int)EnumWindowsStyle.WS_VISIBLE | (int)EnumWindowsStyle.WS_CLIPCHILDREN)) != ((int)EnumWindowsStyle.WS_VISIBLE | (int)EnumWindowsStyle.WS_CLIPCHILDREN) || (GetWindowLong(hwndOwner, (int)EnumGWLIndex.GWL_EXSTYLE) & (int)EnumWindowsStyleEx.WS_EX_TOOLWINDOW) != 0); } return(false); }