DPI Scaling in Windows 8.1 via command line

22,401

Solution 1

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.

Solution 2

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.

Share:
22,401

Related videos on Youtube

FThompson
Author by

FThompson

Updated on September 18, 2022

Comments

  • FThompson
    FThompson over 1 year

    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
    FThompson over 9 years
    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?
  • harrymc
    harrymc over 9 years
    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.
  • FThompson
    FThompson over 9 years
    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.
  • harrymc
    harrymc over 9 years
    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
    harrymc over 9 years
    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.
  • FThompson
    FThompson about 9 years
    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.
  • kokbira
    kokbira almost 8 years
    It does not work on Windows 10 :(
  • kokbira
    kokbira almost 8 years
    You can fuse both answers to generate a procedure to change DPI and another to change resolution to consolidate changes.
  • FlyingFoX
    FlyingFoX over 5 years
    @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.
  • Shayan
    Shayan almost 5 years
    If DPI Scale is different for each monitor, instead of HKCU:\Control Panel\Desktop look HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics\AppliedDPI
  • Shayan
    Shayan almost 5 years
    And also here HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\GraphicsDriv‌​ers\ScaleFactors