16

I'd like to create a keyboard shortcut to quickly and easily change the DPI scale on my machine, by means of creating a small macro to run upon detection of the keyboard shortcut.

In Windows 8.1, the desktop display DPI scale can be set via the control panel (pictured below), taking effect immediately. Alternatively, the scale can be set manually in the registry, but doing so requires that the user sign in and out or restart the machine in order to take effect (and only works to imitate the "one scaling level for all my displays" option).

How can I set the DPI scale via the command line, or otherwise programmatically?

http://puu.sh/93YLV.jpg

FThompson
  • 385
  • 1
  • 3
  • 10

2 Answers2

10

The correct registry key for monitor independent scaling is HKCU:\Control Panel\Desktop with the value LogPixels. More Information about all DPI-related registry settings can be found here: http://technet.microsoft.com/en-us/library/dn528846.aspx#system There are also information for the case when you enabled different scaling for each display.

I wrote a tiny PowerShell script that changes the DPI scaling for all displays depending on the current scaling and performs the user logoff so i just have to execute the script when I put my device to a different monitor.

cd 'HKCU:\Control Panel\Desktop'
$val = Get-ItemProperty -Path . -Name "LogPixels"
if($val.LogPixels -ne 96)
{
    Write-Host 'Change to 100% / 96 dpi'
    Set-ItemProperty -Path . -Name LogPixels -Value 96
} else {
    Write-Host 'Change to 150% / 144 dpi'
    Set-ItemProperty -Path . -Name LogPixels -Value 144
}

logoff;exit

I think you can modify it for your needs with the information of the TechNet article.

Torben Schramme
  • 201
  • 2
  • 4
3

There is PowerShell script to change screen resolution which might help. I have no idea if the change it does is immediate on Windows 8.1, but with a bit of luck this script might use the same API as used by the Control Panel applet.

The complete Set-ScreenResolution.ps1 script is available in the Script Repository, but is too long to reproduce here.

Its description by the author can be found in the article :
Hey, Scripting Guy! How Can I Change My Desktop Monitor Resolution via Windows PowerShell?.

Some information on using it can be found in the article :
Changing Screen Resolution with Powershell.

kokbira
  • 5,429
harrymc
  • 498,455