Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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