From a948c6f793664013e18932a867134a5f862f8808 Mon Sep 17 00:00:00 2001 From: Jaex Date: Sun, 16 Oct 2016 01:12:15 +0300 Subject: [PATCH] #1960: Also ignore cloaked windows in region capture --- ShareX.HelpersLib/Native/NativeMethods_Helpers.cs | 12 +++++++----- .../RegionHelpers/WindowsRectangleList.cs | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ShareX.HelpersLib/Native/NativeMethods_Helpers.cs b/ShareX.HelpersLib/Native/NativeMethods_Helpers.cs index 3f69b57e3..b276ded6b 100644 --- a/ShareX.HelpersLib/Native/NativeMethods_Helpers.cs +++ b/ShareX.HelpersLib/Native/NativeMethods_Helpers.cs @@ -351,12 +351,14 @@ public static bool IsWindowMaximized(IntPtr handle) public static bool IsWindowCloaked(IntPtr handle) { - if (!IsDWMEnabled()) - return false; + if (IsDWMEnabled()) + { + int cloaked; + int result = DwmGetWindowAttribute(handle, (int)DwmWindowAttribute.Cloaked, out cloaked, sizeof(int)); + return result == 0 && cloaked != 0; + } - int cloaked; - int result = DwmGetWindowAttribute(handle, (int)DwmWindowAttribute.Cloaked, out cloaked, sizeof(int)); - return result == 0 && cloaked != 0; + return false; } public static IntPtr SetHook(int hookType, HookProc hookProc) diff --git a/ShareX.ScreenCaptureLib/RegionHelpers/WindowsRectangleList.cs b/ShareX.ScreenCaptureLib/RegionHelpers/WindowsRectangleList.cs index 3ce92f589..8d0e8404a 100644 --- a/ShareX.ScreenCaptureLib/RegionHelpers/WindowsRectangleList.cs +++ b/ShareX.ScreenCaptureLib/RegionHelpers/WindowsRectangleList.cs @@ -111,7 +111,7 @@ private bool EvalControl(IntPtr hWnd, IntPtr lParam) private bool CheckHandle(IntPtr handle, bool isWindow) { - if (handle == IgnoreHandle || !NativeMethods.IsWindowVisible(handle)) + if (handle == IgnoreHandle || !NativeMethods.IsWindowVisible(handle) || (isWindow && NativeMethods.IsWindowCloaked(handle))) { return true; }