Skip to content

Instantly share code, notes, and snippets.

@13xforever
Created January 9, 2018 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 13xforever/f607eae240ac1a01712ee37f4d43b8c0 to your computer and use it in GitHub Desktop.
Save 13xforever/f607eae240ac1a01712ee37f4d43b8c0 to your computer and use it in GitHub Desktop.
if ([System.Environment]::OSVersion.Version.Major -lt 6) { throw "Unsupported OS" }
$aeroEnablerSource = @'
using System;
using System.Runtime.InteropServices;
namespace CustomInterop
{
[Flags]
public enum DWM_BB
{
Enable = 1,
BlurRegion = 2,
TransitionMaximized = 4
}
[StructLayout(LayoutKind.Sequential)]
public struct DWM_BLURBEHIND
{
public DWM_BB dwFlags;
public bool fEnable;
public IntPtr hRgnBlur;
public bool fTransitionOnMaximized;
}
public static class AeroEnabler
{
[DllImport("dwmapi.dll")]
private static extern void DwmEnableBlurBehindWindow(IntPtr hwnd, ref DWM_BLURBEHIND blurBehind);
public static void DwmEnableBlurBehindWindow(IntPtr hwnd)
{
var blurBehindParam = new DWM_BLURBEHIND
{
dwFlags = DWM_BB.Enable | DWM_BB.TransitionMaximized,
fEnable = true,
fTransitionOnMaximized = true,
};
DwmEnableBlurBehindWindow(hwnd, ref blurBehindParam);
}
}
}
'@
Add-Type -TypeDefinition $aeroEnablerSource -Language CSharpVersion3
function Enable-Aero($windowName)
{
Get-Process $windowName | %{ [CustomInterop.AeroEnabler]::DwmEnableBlurBehindWindow($_.MainWindowHandle) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment