; A_ScreenDPI 将返回系统 dpi,在多显示器设置中,它可能会返回主显示器的 DPI, hwnd := WinExist("A") for Each, hMonitor in EnumMonitors() { dpi := GetDpiForMonitor(hMonitor) List .= Each ". " hMonitor " " dpi.x " " dpi.y " " GetDpiForWindow(hwnd) "`n" } MsgBox % List ; https://www.autohotkey.com/boards/viewtopic.php?f=76&t=40892 EnumMonitors() { static EnumProc := RegisterCallback("MonitorEnumProc") Monitors := [] return DllCall("User32\EnumDisplayMonitors", "Ptr", 0, "Ptr", 0, "Ptr", EnumProc, "Ptr", &Monitors, "Int") ? Monitors : false } MonitorEnumProc(hMonitor, hDC, pRECT, ObjectAddr) { Monitors := Object(ObjectAddr) Monitors.Push(hMonitor) return true } GetDpiForMonitor(hMonitor, Monitor_Dpi_Type := 0) { ; MDT_EFFECTIVE_DPI = 0 (shellscalingapi.h) if !DllCall("Shcore\GetDpiForMonitor", "Ptr", hMonitor, "UInt", Monitor_Dpi_Type, "UInt*", dpiX, "UInt*", dpiY, "UInt") return {x:dpiX, y:dpiY} } GetDpiForWindow(hwnd) { return DllCall("User32\GetDpiForWindow", "Ptr", hwnd, "UInt") }
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)