Created
January 9, 2018 10:05
-
-
Save 13xforever/f607eae240ac1a01712ee37f4d43b8c0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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