本帖最后由 sanmoking 于 2020-4-30 09:52 编辑
我的surface目前dpi缩放200%,用获取指定坐标颜色值一直不准,坐标值需要乘以200%这个系数,全网找了好久都不好使,最后发现这个代码,缝缝补补凑合用一下。
$dpizoom = DPIzoom()
$pixx=@DesktopWidth
$pixy=@DesktopHeight
$iColora = Hex(PixelGetColor($pixx, $pixy), 6)
$iColorb = Hex(PixelGetColor($pixx*$dpizoom, $pixy*$dpizoom), 6)
MsgBox(0,0,"坐标"&$pixx&","&$pixy&"的颜色值为:"&$iColora&@CRLF&"坐标换算后"&$pixx*$dpizoom&","&$pixy*$dpizoom&"的颜色值为:"&$iColorb)
func DPIzoom()
$dpizoomtmp = 1
$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
$colSettings = $objWMIService.ExecQuery("Select * from Win32_DesktopMonitor")
For $objOperatingSystem In $colSettings
$tmp = $objOperatingSystem.PNPDeviceID
$EDID = RegRead("HKLM\SYSTEM\CurrentControlSet\Enum" & $tmp & "\Device Parameters", "EDID")
If $EDID <> "" Then
$Width = Int(BinaryMid($EDID, 57, 1)) + BitAND(Int(BinaryMid($EDID, 57 + 2, 1)), 240) * 16
;~ $Height = Int(BinaryMid($EDID, 57 + 3, 1)) + BitAND(Int(BinaryMid($EDID, 57 + 5, 1)), 240) * 16
$dpizoomtmp = $Width/@DesktopWidth
EndIf
Next
Return $dpizoomtmp
EndFunc
|