From 8d458b66a50f5c495eefbf5ffb1c39ea406c3e4c Mon Sep 17 00:00:00 2001 From: vcaesar Date: Wed, 9 Jan 2019 13:24:06 -0400 Subject: [PATCH] add mul scale func and optimize code --- robotgo.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/robotgo.go b/robotgo.go index a12555a..ac40e88 100644 --- a/robotgo.go +++ b/robotgo.go @@ -235,6 +235,12 @@ func Scale() int { return dpi[x] } +// Mul mul the scale +func Mul(x int) int { + s := Scale() + return x * s / 100 +} + // GetScaleSize get the screen scale size func GetScaleSize() (int, int) { x, y := GetScreenSize() @@ -291,13 +297,7 @@ func CaptureScreen(args ...int) C.MMBitmapRef { // GoCaptureScreen capture the screen and return bitmap(go struct) func GoCaptureScreen(args ...int) Bitmap { - var bit C.MMBitmapRef - - if len(args) > 3 { - bit = CaptureScreen(args[0], args[1], args[2], args[3]) - } else { - bit = CaptureScreen() - } + bit := CaptureScreen(args...) defer FreeBitmap(bit) return ToBitmap(bit) @@ -411,10 +411,10 @@ func MoveSmooth(x, y int, args ...interface{}) bool { // GetMousePos get mouse's portion func GetMousePos() (int, int) { pos := C.get_mouse_pos() - // fmt.Println("pos:###", pos, pos.x, pos.y) + x := int(pos.x) y := int(pos.y) - // return pos.x, pos.y + return x, y }