Skip to content

Instantly share code, notes, and snippets.

@itsho
Created December 20, 2018 09:41
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save itsho/cc4f0c66d3283a6b54582fde31b70a26 to your computer and use it in GitHub Desktop.
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
# =========================================================================================================
# 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;
@cubicsfolly
Copy link

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

@itsho
Copy link
Author

itsho commented Aug 23, 2023

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