mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-29 21:43:55 +00:00
Unifed and rename some function for Pad
This commit is contained in:
parent
c3cda41c2d
commit
4bf054f47a
@ -55,7 +55,7 @@ func click() {
|
||||
|
||||
func get() {
|
||||
// gets the mouse coordinates
|
||||
x, y := robotgo.GetMousePos()
|
||||
x, y := robotgo.Location()
|
||||
fmt.Println("pos:", x, y)
|
||||
if x == 456 && y == 586 {
|
||||
fmt.Println("mouse...", "586")
|
||||
@ -66,8 +66,8 @@ func get() {
|
||||
|
||||
func toggleAndScroll() {
|
||||
// scrolls the mouse either up
|
||||
robotgo.ScrollMouse(10, "up")
|
||||
robotgo.ScrollMouse(10, "right")
|
||||
robotgo.ScrollDir(10, "up")
|
||||
robotgo.ScrollDir(10, "right")
|
||||
|
||||
robotgo.Scroll(100, 10)
|
||||
robotgo.Scroll(0, -10)
|
||||
|
@ -33,6 +33,9 @@ func TestGetScreenSize(t *testing.T) {
|
||||
|
||||
rect := robotgo.GetScreenRect()
|
||||
fmt.Println("Get screen rect: ", rect)
|
||||
|
||||
x, y = robotgo.Location()
|
||||
fmt.Println("Get location: ", x, y)
|
||||
}
|
||||
|
||||
func TestGetSysScale(t *testing.T) {
|
||||
|
19
robotgo.go
19
robotgo.go
@ -624,7 +624,7 @@ func MoveSmooth(x, y int, args ...interface{}) bool {
|
||||
|
||||
// MoveArgs get the mouse relative args
|
||||
func MoveArgs(x, y int) (int, int) {
|
||||
mx, my := GetMousePos()
|
||||
mx, my := Location()
|
||||
mx = mx + x
|
||||
my = my + y
|
||||
|
||||
@ -642,8 +642,15 @@ func MoveSmoothRelative(x, y int, args ...interface{}) {
|
||||
MoveSmooth(mx, my, args...)
|
||||
}
|
||||
|
||||
// Deprecated: use the function Location()
|
||||
//
|
||||
// GetMousePos get the mouse's position return x, y
|
||||
func GetMousePos() (int, int) {
|
||||
return Location()
|
||||
}
|
||||
|
||||
// Location get the mouse location position return x, y
|
||||
func Location() (int, int) {
|
||||
pos := C.getMousePos()
|
||||
x := int(pos.x)
|
||||
y := int(pos.y)
|
||||
@ -773,17 +780,17 @@ func Scroll(x, y int, args ...int) {
|
||||
MilliSleep(MouseSleep + msDelay)
|
||||
}
|
||||
|
||||
// ScrollMouse scroll the mouse to (x, "up")
|
||||
// ScrollDir scroll the mouse with direction to (x, "up")
|
||||
// supported: "up", "down", "left", "right"
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
// robotgo.ScrollMouse(10, "down")
|
||||
// robotgo.ScrollMouse(10, "up")
|
||||
func ScrollMouse(x int, direction ...string) {
|
||||
// robotgo.ScrollDir(10, "down")
|
||||
// robotgo.ScrollDir(10, "up")
|
||||
func ScrollDir(x int, direction ...interface{}) {
|
||||
d := "down"
|
||||
if len(direction) > 0 {
|
||||
d = direction[0]
|
||||
d = direction[0].(string)
|
||||
}
|
||||
|
||||
if d == "down" {
|
||||
|
@ -68,8 +68,8 @@ func TestDragMouse(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestScrollMouse(t *testing.T) {
|
||||
ScrollMouse(120, "up")
|
||||
ScrollMouse(100, "right")
|
||||
ScrollDir(120, "up")
|
||||
ScrollDir(100, "right")
|
||||
|
||||
Scroll(0, 120)
|
||||
MilliSleep(100)
|
||||
|
Loading…
Reference in New Issue
Block a user