我們可以使用 WMI 取得文字縮放和監視屬性嗎?

我們可以使用 WMI 取得文字縮放和監視屬性嗎?

可以使用 WMI 來偵測以下內容:

  • 文字縮放
  • 螢幕解析度
  • 多顯示器配置/佈局

我明白了Win32_DesktopMonitor,但它似乎沒有給我任何這些資訊。

答案1

文字縮放:儲存在這兩個用戶註冊表值中:

# AllUsers setting, which shows as (default)
(Get-ItemProperty "HKCU:\Control Panel\Desktop\WindowMetrics").AppliedDPI
# User's current scaling settings for each monitor
(Get-ItemProperty "HKCU:\Control Panel\Desktop\PerMonitorSettings\*").DpiValue

# AppliedDPI shows the "Default" scaling setting on a system level like:
96  : 100% 
120 : 125% 
144 : 150% 
192 : 200%  # (my default)
 
# DpiValue shows how many steps up or down *from Default* the current user's scaling setting is. 
# For example on my machine:
DpiValue : 2           # +2 = 250%
DpiValue : 0           # +0 = 200% (default)
DpiValue : 4294967294  # -1 = 150%
DpiValue : 4294967292  # -3 = 100%

顯示器佈局:

Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Screen]::AllScreens

螢幕解析度:使用AllScreens上面的枚舉,或其中之一:

Get-CimInstance Win32_DesktopMonitor | select Name,Screen*
Get-CimInstance CIM_VideoController  | Select Name,Current*

相關內容