private static bool IsMainWindow(IntPtr windowHandle) { var style = (WindowStyles)User32Helpers.GetWindowLongPtr(windowHandle, WindowLongFlags.GWL_STYLE); var isMinimized = (style & WindowStyles.WS_MINIMIZE) == WindowStyles.WS_MINIMIZE; return (User32Methods.IsWindow(windowHandle) && (User32Methods.IsWindowVisible(windowHandle) || isMinimized)); }