Hide background UWP apps from window capture options

UWP apps that aren't shown are 'cloaked'
This commit is contained in:
campbeb 2016-10-15 16:41:25 -04:00
parent d89dd984f4
commit 1bfb545d33
4 changed files with 16 additions and 1 deletions

View file

@ -207,6 +207,9 @@ public enum DwmWindowAttribute
HasIconicBitmap,
DisallowPeek,
ExcludedFromPeek,
Cloak,
Cloaked,
FreezeRepresentation,
Last
}

View file

@ -392,6 +392,9 @@ public static partial class NativeMethods
[DllImport("dwmapi.dll")]
public static extern int DwmGetWindowAttribute(IntPtr hwnd, int dwAttribute, out bool pvAttribute, int cbAttribute);
[DllImport("dwmapi.dll")]
public static extern int DwmGetWindowAttribute(IntPtr hwnd, int dwAttribute, out int pvAttribute, int cbAttribute);
[DllImport("dwmapi.dll")]
public static extern void DwmEnableBlurBehindWindow(IntPtr hwnd, ref DWM_BLURBEHIND blurBehind);

View file

@ -349,6 +349,13 @@ public static bool IsWindowMaximized(IntPtr handle)
return wp.showCmd == WindowShowStyle.Maximize;
}
public static bool IsWindowCloaked(IntPtr handle)
{
int cloaked;
int result = DwmGetWindowAttribute(handle, (int)DwmWindowAttribute.Cloaked, out cloaked, sizeof(int));
return result == 0 && cloaked != 0;
}
public static IntPtr SetHook(int hookType, HookProc hookProc)
{
using (Process currentProcess = Process.GetCurrentProcess())

View file

@ -54,7 +54,9 @@ public class WindowInfo
public bool IsMinimized => NativeMethods.IsIconic(Handle);
public bool IsVisible => NativeMethods.IsWindowVisible(Handle);
public bool IsVisible => NativeMethods.IsWindowVisible(Handle) && !IsCloaked;
public bool IsCloaked => NativeMethods.IsWindowCloaked(Handle);
public bool IsActive => NativeMethods.GetForegroundWindow() == Handle;