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?
-
4Is this a UNIX/Linux question?Jim L.– Jim L.2022-08-16 19:02:40 +00:00Commented 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 scalingphuclv– phuclv2024-09-19 04:27:45 +00:00Commented Sep 19, 2024 at 4:27
Add a comment
|
1 Answer
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.