Powershell は、すべてのモニターのモニター DPI スケーリングを取得します。

Powershell は、すべてのモニターのモニター DPI スケーリングを取得します。

参照されたDPIクラススクリプトの使用ここプライマリモニタのDPIスケーリングを取得できますか?別のスケーリング要素がある可能性がある他のモニターから出力を取得するにはどうすればよいですか?

ベストアンサー1

私はpowershell 7を使用しており、次のコードを使用しています。

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

もっと良いこと

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

VideoController 配列を繰り返すことで、各モニターに対して同じ値を得ることができます。

おすすめ記事