Change “Windows font size (DPI)” in PowerShell?

后端 未结 7 2008
别那么骄傲
别那么骄傲 2020-12-08 17:20

I\'m using a laptop at office (Windows 7) with a station and double screen and at home without station.

The point is I have to change text size each time I switch fr

7条回答
  •  一向
    一向 (楼主)
    2020-12-08 18:04

    As supposed in the other answers, the setting under HKLM is not the correct place as the dpi scaling is a user defined setting. The correct registry key is HKCU:\Control Panel\Desktop with the value LogPixels.

    More information about all DPI-related registry settings can be found in DPI-related APIs and registry settings.

    I wrote a tiny PowerShell script that changes the DPI scaling 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
    

提交回复
热议问题