Unifed and rename some function for Pad

This commit is contained in:
vcaesar 2022-11-01 10:28:00 -07:00
parent c3cda41c2d
commit 4bf054f47a
4 changed files with 21 additions and 11 deletions

View File

@ -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)

View File

@ -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) {

View File

@ -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" {

View File

@ -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)