DPI Scaling in Windows 8.1 via command line
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.
Related videos on Youtube
FThompson
Updated on September 18, 2022Comments
-
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?
-
FThompson over 9 yearsThese 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 over 9 yearsChanging 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 over 9 yearsWhile 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 over 9 yearsThis 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 over 9 yearsExplorer 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 about 9 yearsMy 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 almost 8 yearsIt does not work on Windows 10 :(
-
kokbira almost 8 yearsYou can fuse both answers to generate a procedure to change DPI and another to change resolution to consolidate changes.
-
FlyingFoX over 5 years@kokbira For this to work in Windows 10 you need to set the registry key
HKCU:\Control Panel\Desktop\Win8DpiScaling
to1
. Otherwise it will use the default scaling factor and ignore the value inLogPixels
. -
Shayan almost 5 yearsIf DPI Scale is different for each monitor, instead of
HKCU:\Control Panel\Desktop
lookHKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics\AppliedDPI
-
Shayan almost 5 yearsAnd also here
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\GraphicsDrivers\ScaleFactors