mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-05 00:03:55 +00:00
add mul scale func and optimize code
This commit is contained in:
parent
5e6c44832f
commit
8d458b66a5
18
robotgo.go
18
robotgo.go
@ -235,6 +235,12 @@ func Scale() int {
|
|||||||
return dpi[x]
|
return dpi[x]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mul mul the scale
|
||||||
|
func Mul(x int) int {
|
||||||
|
s := Scale()
|
||||||
|
return x * s / 100
|
||||||
|
}
|
||||||
|
|
||||||
// GetScaleSize get the screen scale size
|
// GetScaleSize get the screen scale size
|
||||||
func GetScaleSize() (int, int) {
|
func GetScaleSize() (int, int) {
|
||||||
x, y := GetScreenSize()
|
x, y := GetScreenSize()
|
||||||
@ -291,13 +297,7 @@ func CaptureScreen(args ...int) C.MMBitmapRef {
|
|||||||
|
|
||||||
// GoCaptureScreen capture the screen and return bitmap(go struct)
|
// GoCaptureScreen capture the screen and return bitmap(go struct)
|
||||||
func GoCaptureScreen(args ...int) Bitmap {
|
func GoCaptureScreen(args ...int) Bitmap {
|
||||||
var bit C.MMBitmapRef
|
bit := CaptureScreen(args...)
|
||||||
|
|
||||||
if len(args) > 3 {
|
|
||||||
bit = CaptureScreen(args[0], args[1], args[2], args[3])
|
|
||||||
} else {
|
|
||||||
bit = CaptureScreen()
|
|
||||||
}
|
|
||||||
defer FreeBitmap(bit)
|
defer FreeBitmap(bit)
|
||||||
|
|
||||||
return ToBitmap(bit)
|
return ToBitmap(bit)
|
||||||
@ -411,10 +411,10 @@ func MoveSmooth(x, y int, args ...interface{}) bool {
|
|||||||
// GetMousePos get mouse's portion
|
// GetMousePos get mouse's portion
|
||||||
func GetMousePos() (int, int) {
|
func GetMousePos() (int, int) {
|
||||||
pos := C.get_mouse_pos()
|
pos := C.get_mouse_pos()
|
||||||
// fmt.Println("pos:###", pos, pos.x, pos.y)
|
|
||||||
x := int(pos.x)
|
x := int(pos.x)
|
||||||
y := int(pos.y)
|
y := int(pos.y)
|
||||||
// return pos.x, pos.y
|
|
||||||
return x, y
|
return x, y
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user