diff --git a/robotgo.go b/robotgo.go index 0d0f699..48c61e5 100644 --- a/robotgo.go +++ b/robotgo.go @@ -188,13 +188,43 @@ func GetPixelColor(x, y int) string { return gcolor } -// GetScreenSize get screen size +// ScaleX get primary display horizontal DPI scale factor +func ScaleX() int { + return int(C.scalex()) +} + +// ScaleY get primary display vertical DPI scale factor +func ScaleY() int { + return int(C.scaley()) +} + +// GetScreenSize get the screen size func GetScreenSize() (int, int) { size := C.get_screen_size() // fmt.Println("...", size, size.width) return int(size.width), int(size.height) } +// Scale get the screen scale +func Scale() int { + dpi := map[int]int{ + 96: 100, + 120: 125, + 144: 150, + 192: 200, + } + + x := ScaleX() + return dpi[x] +} + +// GetScaleSize get the screen scale size +func GetScaleSize() (int, int) { + x, y := GetScreenSize() + s := Scale() + return x * s / 100, y * s / 100 +} + // SetXDisplayName set XDisplay name func SetXDisplayName(name string) string { cname := C.CString(name) @@ -1293,16 +1323,6 @@ ____ __ ____ __ .__ __. _______ ______ ____ __ ____ */ -// ScaleX get primary display horizontal DPI scale factor -func ScaleX() int { - return int(C.scalex()) -} - -// ScaleY get primary display vertical DPI scale factor -func ScaleY() int { - return int(C.scaley()) -} - // ShowAlert show a alert window func ShowAlert(title, msg string, args ...string) int { var (