mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-29 21:43:55 +00:00
Update: fixed windows scale move and Location(), update godoc
This commit is contained in:
parent
cbca6d08c7
commit
ffcf6b26cd
4
key.go
4
key.go
@ -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:
|
||||
//
|
||||
|
15
robotgo.go
15
robotgo.go
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user