Created
December 20, 2018 09:41
-
-
Save itsho/cc4f0c66d3283a6b54582fde31b70a26 to your computer and use it in GitHub Desktop.
Force 100% DPI Scaling for all screens even if the default value is different
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ========================================================================================================= | |
# if you like to reset your DPI Scaling to the DEFAULT, you can use the registry (Option five) from here: | |
# https://www.tenforums.com/tutorials/5990-change-dpi-scaling-level-displays-windows-10-a.html#option5 | |
# | |
# But, since the default value is different on various monitors, if you like to force 100%, | |
# you need the following trick: | |
# for each monitor - set DPIValue to 0xFFFFFFFF (which is -1 in DWord) | |
# | |
# Last update: 18 December 2018 | |
# Created by: Itsho | |
# ========================================================================================================= | |
# -1 == 0xFFFFFFFF in DWord == 100% DPI scaling | |
# 0 = default setting of the screen (can be 125%!) | |
# 1 = default settings + 1 | |
# 2 = default settings + 2 | |
$dpiValue = -1 | |
$activeMonitorsRegPath = "HKCU:\Control Panel\Desktop\PerMonitorSettings" | |
$genericMonitorsList = Get-ChildItem HKLM:\System\CurrentControlSet\Control\GraphicsDrivers\ScaleFactors | |
Write-Host( [string]::Format("Found {0} ScaleFactors monitors", $genericMonitorsList.Length)); | |
foreach ($genericMonitor in $genericMonitorsList) { | |
$tempRegPath = $activeMonitorsRegPath + '\' + $genericMonitor.PsChildname; | |
# if registry KEY already exists | |
if (Test-Path -Path $tempRegPath) { | |
Write-Host('Updating value for monitor - ' + $genericMonitor.PsChildname) | |
# update existing-item DPI's value | |
Set-ItemProperty -Path $tempRegPath -Name 'DpiValue' -Value $dpiValue –Force | |
} else { | |
Write-Host('Creating new key and value for monitor - ' + $genericMonitor.PsChildname) | |
# create new key under PerMonitorSettings | |
New-Item -Path $activeMonitorsRegPath -Name $genericMonitor.PsChildname –Force | Out-Null | |
# create new value | |
New-ItemProperty -Path $tempRegPath -Name 'DpiValue' -PropertyType DWord -Value $dpiValue –Force | Out-Null | |
} | |
} | |
# Notice - disposing registry objects is mandatory when loading hive of a different user. | |
# otherwise you won't be able to unload the hive... | |
$genericMonitorsList.Close(); | |
$genericMonitorsList = $null; |
That's an interesting find, and you are most probably right.
Thank you for the comment 🙂
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you! I've been looking for something like this for a long time! However, if the monitor's default scale is not 125% but 150%, or 175%, etc. then $dpiValue must be changed accordingly. E.g. if default is 150%, $dpiValue must be -2, etc. essentially, the negative value of HKLM:\System\CurrentControlSet\Control\GraphicsDrivers\ScaleFactors<monitor_id>\DpiValue