mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-30 22:13:54 +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:
|
// 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:
|
// Examples:
|
||||||
//
|
//
|
||||||
@ -532,7 +532,7 @@ func KeyTap(key string, args ...interface{}) error {
|
|||||||
//
|
//
|
||||||
// See keys:
|
// 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:
|
// Examples:
|
||||||
//
|
//
|
||||||
|
15
robotgo.go
15
robotgo.go
@ -92,7 +92,7 @@ type (
|
|||||||
//
|
//
|
||||||
// The common type conversion of bitmap:
|
// 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 {
|
type Bitmap struct {
|
||||||
ImgBuf *uint8
|
ImgBuf *uint8
|
||||||
Width, Height int
|
Width, Height int
|
||||||
@ -270,6 +270,11 @@ func Scaled0(x int, f float64) int {
|
|||||||
return int(float64(x) * f)
|
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
|
// GetScreenSize get the screen size
|
||||||
func GetScreenSize() (int, int) {
|
func GetScreenSize() (int, int) {
|
||||||
size := C.getMainDisplaySize()
|
size := C.getMainDisplaySize()
|
||||||
@ -332,6 +337,7 @@ func CaptureScreen(args ...int) CBitmap {
|
|||||||
x = C.int32_t(rect.X)
|
x = C.int32_t(rect.X)
|
||||||
y = C.int32_t(rect.Y)
|
y = C.int32_t(rect.Y)
|
||||||
}
|
}
|
||||||
|
|
||||||
w = C.int32_t(rect.W)
|
w = C.int32_t(rect.W)
|
||||||
h = C.int32_t(rect.H)
|
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) {
|
func MoveScale(x, y int, displayId ...int) (int, int) {
|
||||||
if Scale && runtime.GOOS == "windows" {
|
if Scale && runtime.GOOS == "windows" {
|
||||||
f := ScaleF()
|
f := ScaleF()
|
||||||
x, y = Scaled0(x, f), Scaled0(y, f)
|
x, y = Scaled1(x, f), Scaled1(y, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
return x, y
|
return x, y
|
||||||
@ -611,6 +617,11 @@ func Location() (int, int) {
|
|||||||
x := int(pos.x)
|
x := int(pos.x)
|
||||||
y := int(pos.y)
|
y := int(pos.y)
|
||||||
|
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
f := ScaleF()
|
||||||
|
x, y = Scaled0(x, f), Scaled0(y, f)
|
||||||
|
}
|
||||||
|
|
||||||
return x, y
|
return x, y
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user