Update: fixed windows scale move and Location(), update godoc

This commit is contained in:
vcaesar 2023-03-13 11:07:26 -07:00
parent cbca6d08c7
commit ffcf6b26cd
2 changed files with 15 additions and 4 deletions

4
key.go
View File

@ -484,7 +484,7 @@ func toErr(str *C.char) error {
//
// See keys supported:
//
// https://github.com/go-vgo/robotgo/blob/master/docs/keys.md
// https://github.com/go-vgo/robotgo/blob/master/docs/keys.md#keys
//
// Examples:
//
@ -532,7 +532,7 @@ func KeyTap(key string, args ...interface{}) error {
//
// See keys:
//
// https://github.com/go-vgo/robotgo/blob/master/docs/keys.md
// https://github.com/go-vgo/robotgo/blob/master/docs/keys.md#keys
//
// Examples:
//

View File

@ -92,7 +92,7 @@ type (
//
// The common type conversion of bitmap:
//
// https://github.com/go-vgo/robotgo/blob/master/docs/keys.md
// https://github.com/go-vgo/robotgo/blob/master/docs/keys.md#type-conversion
type Bitmap struct {
ImgBuf *uint8
Width, Height int
@ -270,6 +270,11 @@ func Scaled0(x int, f float64) int {
return int(float64(x) * f)
}
// Scaled1 return int(x / f)
func Scaled1(x int, f float64) int {
return int(float64(x) / f)
}
// GetScreenSize get the screen size
func GetScreenSize() (int, int) {
size := C.getMainDisplaySize()
@ -332,6 +337,7 @@ func CaptureScreen(args ...int) CBitmap {
x = C.int32_t(rect.X)
y = C.int32_t(rect.Y)
}
w = C.int32_t(rect.W)
h = C.int32_t(rect.H)
}
@ -487,7 +493,7 @@ func CheckMouse(btn string) C.MMMouseButton {
func MoveScale(x, y int, displayId ...int) (int, int) {
if Scale && runtime.GOOS == "windows" {
f := ScaleF()
x, y = Scaled0(x, f), Scaled0(y, f)
x, y = Scaled1(x, f), Scaled1(y, f)
}
return x, y
@ -611,6 +617,11 @@ func Location() (int, int) {
x := int(pos.x)
y := int(pos.y)
if runtime.GOOS == "windows" {
f := ScaleF()
x, y = Scaled0(x, f), Scaled0(y, f)
}
return x, y
}