系统高DPI情况下获取指定像素颜色等坐标需要机选缩放比例
本帖最后由 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
收藏!等换高分屏肯定用得到。。。 收藏!收藏! 没看懂,不是有显示相关的API么 谢谢分享,楼主辛苦!
页:
[1]