Skip to content

Instantly share code, notes, and snippets.

@607011
Created May 27, 2014 12:31
Show Gist options
  • Save 607011/24dd130ef623ffd62d22 to your computer and use it in GitHub Desktop.
Save 607011/24dd130ef623ffd62d22 to your computer and use it in GitHub Desktop.
Cleartype on/off
param([bool]$enable)
$signature = @'
[DllImport("user32.dll")]
public static extern bool SystemParametersInfo(
uint uiAction,
uint uiParam,
uint pvParam,
uint fWinIni);
'@
$SPI_SETFONTSMOOTHING = 0x004B
$SPI_SETFONTSMOOTHINGTYPE = 0x200B
$SPIF_UPDATEINIFILE = 0x1
$SPIF_SENDCHANGE = 0x2
$FE_FONTSMOOTHINGCLEARTYPE = 0x2
$winapi = Add-Type -MemberDefinition $signature -Name WinAPI -PassThru
if ($enable)
{
[void]$winapi::SystemParametersInfo($SPI_SETFONTSMOOTHING, 1, 0, $SPIF_UPDATEINIFILE -bor $SPIF_SENDCHANGE)
[void]$winapi::SystemParametersInfo($SPI_SETFONTSMOOTHINGTYPE, 0, $FE_FONTSMOOTHINGCLEARTYPE, $SPIF_UPDATEINIFILE -bor $SPIF_SENDCHANGE)
}
else
{
[void]$winapi::SystemParametersInfo($SPI_SETFONTSMOOTHING, 0, 0, $SPIF_UPDATEINIFILE -bor $SPIF_SENDCHANGE)
}
@607011
Copy link
Author

607011 commented May 27, 2014

Turn Cleartype on:

  • powershell -executionpolicy bypass cleartype.ps1 1

Turn Cleartype off:

  • powershell -executionpolicy bypass cleartype.ps1 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment