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

5
  • Have you tried making the registry change, killing the explorer process, then starting it again. Because thats all the GUI method would do in theory.
    – Ramhound
    May 27, 2014 at 22:50
  • @Ramhound No luck. The GUI interface is definitely doing something to refresh the desktop in order to apply the setting, but I'm not sure what and haven't been able to find anything about it.
    – FThompson
    May 27, 2014 at 23:33
  • Are you sure the changes take place immediately? I get a dialog saying "You must sign out of your computer to apply these changes"
    – Vinayak
    Aug 24, 2014 at 18:30
  • @Vinayak, The changes take place immediately when applied by the above dialog. I do recall reading that the immediate-application is new to Windows 8.1 over standard Windows 8, so if you're interested it researching that difference between your machine and mine, that could be a place to start.
    – FThompson
    Aug 24, 2014 at 18:58
  • @Vulcan Actually, I am using Windows 8.1. However, I was trying to make changes after clicking on the Let me choose one scaling level... checkbox as the slider above it is greyed out on my notebook.
    – Vinayak
    Aug 24, 2014 at 19:02

2 Answers 2

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.

5
  • 3
    My apologies for not responding sooner; great solution! Unfortunately, however, using the LogPixels value only applies when the "Let me choose one scaling level for all my displays" checkbox is checked, something I had observed when messing with the registry values myself but is also confirmed by the linked Technet article. Also, your solution has the caveat of requiring user logout; the DPIs aren't updated without the user logging out and back in again. Between these two drawbacks, your solution doesn't quite work for me, but +1 all the same for a great answer.
    – FThompson
    Mar 31, 2015 at 1:11
  • It does not work on Windows 10 :(
    – kokbira
    May 9, 2016 at 19:04
  • 3
    @kokbira For this to work in Windows 10 you need to set the registry key HKCU:\Control Panel\Desktop\Win8DpiScaling to 1. Otherwise it will use the default scaling factor and ignore the value in LogPixels.
    – FlyingFoX
    Aug 30, 2018 at 9:36
  • 1
    If DPI Scale is different for each monitor, instead of HKCU:\Control Panel\Desktop look HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics\AppliedDPI
    – Shayan
    May 17, 2019 at 11:11
  • 1
    And also here HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\GraphicsDrivers\ScaleFactors
    – Shayan
    May 17, 2019 at 15:53
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.

6
  • These resources look more oriented towards changing the screen resolution rather than the DPI. I looked at the links you provided, but I only see options to set the width and height, and no mention of DPI. Am I misunderstanding your answer?
    – FThompson
    Aug 26, 2014 at 16:32
  • Changing the resolution will change the DPI and vice verso. You could find out the screen resolution under different DPI settings, then change to these resolutions using the above script.
    – harrymc
    Aug 26, 2014 at 17:59
  • 1
    While changing the resolution does change the DPI, it's not quite the same thing as the DPI scaling offered in Win8 (maybe it's different on other operating systems?) An example of this is that regardless of what the DPI scaling is set to, the desktop and its icons are always the same in size and appearance, whereas if the resolution is changed, the desktop and its icons change in size accordingly.
    – FThompson
    Aug 27, 2014 at 3:01
  • This is because of the new DPI-aware technology introduced in Windows 8.1. I haven't been able to find any information about its API - only registry setting are currently available, which is not what you are looking for.
    – harrymc
    Aug 27, 2014 at 7:02
  • Explorer is DPI-aware so desktop icons keep their size, but very few other programs are. For most products, changing the resolution is as good as changing the DPI.
    – harrymc
    Aug 28, 2014 at 11:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .