PoshCode Archive  Artifact [5de2b4252b]

Artifact 5de2b4252b56654d0ba83b244aa6b4c704f9209e2e9169db303003229c29fdc5:

  • File Aero-Glass-PowerShell.ps1 — part of check-in [fcdae5b581] at 2018-06-10 13:59:51 on branch trunk — Enable aero “glass” effects for the regular powershell 2.0 console (not ISE) – vista or above, powershell 2+ and aero-compatible gfx card. (user: Oisin Grehan size: 1642)

# 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: 5712
# x-archived: 2015-10-22T06:37:53
# x-published: 2015-01-25T08:03: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."

}