mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-04 04:06:05 +13:00
Hide background UWP apps from window capture options
UWP apps that aren't shown are 'cloaked'
This commit is contained in:
parent
d89dd984f4
commit
1bfb545d33
4 changed files with 16 additions and 1 deletions
|
@ -207,6 +207,9 @@ public enum DwmWindowAttribute
|
||||||
HasIconicBitmap,
|
HasIconicBitmap,
|
||||||
DisallowPeek,
|
DisallowPeek,
|
||||||
ExcludedFromPeek,
|
ExcludedFromPeek,
|
||||||
|
Cloak,
|
||||||
|
Cloaked,
|
||||||
|
FreezeRepresentation,
|
||||||
Last
|
Last
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -392,6 +392,9 @@ public static partial class NativeMethods
|
||||||
[DllImport("dwmapi.dll")]
|
[DllImport("dwmapi.dll")]
|
||||||
public static extern int DwmGetWindowAttribute(IntPtr hwnd, int dwAttribute, out bool pvAttribute, int cbAttribute);
|
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")]
|
[DllImport("dwmapi.dll")]
|
||||||
public static extern void DwmEnableBlurBehindWindow(IntPtr hwnd, ref DWM_BLURBEHIND blurBehind);
|
public static extern void DwmEnableBlurBehindWindow(IntPtr hwnd, ref DWM_BLURBEHIND blurBehind);
|
||||||
|
|
||||||
|
|
|
@ -349,6 +349,13 @@ public static bool IsWindowMaximized(IntPtr handle)
|
||||||
return wp.showCmd == WindowShowStyle.Maximize;
|
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)
|
public static IntPtr SetHook(int hookType, HookProc hookProc)
|
||||||
{
|
{
|
||||||
using (Process currentProcess = Process.GetCurrentProcess())
|
using (Process currentProcess = Process.GetCurrentProcess())
|
||||||
|
|
|
@ -54,7 +54,9 @@ public class WindowInfo
|
||||||
|
|
||||||
public bool IsMinimized => NativeMethods.IsIconic(Handle);
|
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;
|
public bool IsActive => NativeMethods.GetForegroundWindow() == Handle;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue