1

Using the DPI class script referenced here I can get DPI scaling for my main monitor how would I also get the output from any additional monitors which may have a separate scaling factor?

2
  • 4
    Is this a UNIX/Linux question? Commented Aug 16, 2022 at 19:02
  • Your linked script is for Windows so obviously it can't work on *nix. If this question is actually about *nix then there's no universal way to get DPI scaling, because not all have GUI, and there are lots of desktop environments. Not all desktop environments support DPI scaling, let alone fractional scaling Commented Sep 19, 2024 at 4:27

1 Answer 1

2

I am using powershell 7 and i used following code:

Add-Type -AssemblyName System.Windows.Forms 
$rh=[int]((Get-CimInstance -ClassName CIM_Display).ScreenHeight | Format-Table -HideTableHeaders | Out-String)
$vh=[int][System.Windows.Forms.SystemInformation]::VirtualScreen.Height
$screen_scale_factor=$rh/$vh

Better still

Add-Type -AssemblyName System.Windows.Forms     
# $rh=[int]((Get-CimInstance -ClassName CIM_Display).ScreenHeight | Format-Table -HideTableHeaders | Out-String)
$rh=[int](Get-CimInstance -ClassName Win32_VideoController)[0].CurrentVerticalResolution
$vh=[int][System.Windows.Forms.SystemInformation]::VirtualScreen.Height
$screen_scale_factor=$rh/$vh

And you could iterate over VideoController array and get the same for every monitor.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.