# encoding: ascii
# api: powershell
# title: Aero Glass PowerShell
# description: Enable aero “glass” effects for the regular powershell 2.0 console (not ISE) – vista or above, powershell 2+ and aero-compatible gfx card.
# version: 0.1
# author: Oisin Grehan
# license: CC0
# x-poshcode-id: 5708
# x-archived: 2015-01-26T20:10:15
# x-published: 2015-01-25T08:02:00
#
# .\glass.ps1 # turn on
# .\glass.ps1 -disable # turn off
#
#requires -version 2
param([switch]$Disable)
add-type -namespace Hacks -name Aero -memberdefinition @"
[StructLayout(LayoutKind.Sequential)]
public struct MARGINS
{
public int left;
public int right;
public int top;
public int bottom;
}
[DllImport("dwmapi.dll", PreserveSig = false)]
public static extern void DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS margins);
[DllImport("dwmapi.dll", PreserveSig = false)]
public static extern bool DwmIsCompositionEnabled();
"@
if (([Environment]::OSVersion.Version.Major -gt 5) -and
[hacks.aero]::DwmIsCompositionEnabled()) {
$hwnd = (get-process -id $pid).mainwindowhandle
$margin = new-object 'hacks.aero+margins'
$host.ui.RawUI.BackgroundColor = "black"
$host.ui.rawui.foregroundcolor = "white"
if ($Disable) {
$margin.top = 0
$margin.left = 0
} else {
$margin.top = -1
$margin.left = -1
}
[hacks.aero]::DwmExtendFrameIntoClientArea($hwnd, [ref]$margin)
} else {
write-warning "Aero is either not available or not enabled on this workstation."
}