Skip to content

Commit 4bf054f

Browse files
committed
Unifed and rename some function for Pad
1 parent c3cda41 commit 4bf054f

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

examples/mouse/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func click() {
5555

5656
func get() {
5757
// gets the mouse coordinates
58-
x, y := robotgo.GetMousePos()
58+
x, y := robotgo.Location()
5959
fmt.Println("pos:", x, y)
6060
if x == 456 && y == 586 {
6161
fmt.Println("mouse...", "586")
@@ -66,8 +66,8 @@ func get() {
6666

6767
func toggleAndScroll() {
6868
// scrolls the mouse either up
69-
robotgo.ScrollMouse(10, "up")
70-
robotgo.ScrollMouse(10, "right")
69+
robotgo.ScrollDir(10, "up")
70+
robotgo.ScrollDir(10, "right")
7171

7272
robotgo.Scroll(100, 10)
7373
robotgo.Scroll(0, -10)

robot_info_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ func TestGetScreenSize(t *testing.T) {
3333

3434
rect := robotgo.GetScreenRect()
3535
fmt.Println("Get screen rect: ", rect)
36+
37+
x, y = robotgo.Location()
38+
fmt.Println("Get location: ", x, y)
3639
}
3740

3841
func TestGetSysScale(t *testing.T) {

robotgo.go

+13-6
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ func MoveSmooth(x, y int, args ...interface{}) bool {
624624

625625
// MoveArgs get the mouse relative args
626626
func MoveArgs(x, y int) (int, int) {
627-
mx, my := GetMousePos()
627+
mx, my := Location()
628628
mx = mx + x
629629
my = my + y
630630

@@ -642,8 +642,15 @@ func MoveSmoothRelative(x, y int, args ...interface{}) {
642642
MoveSmooth(mx, my, args...)
643643
}
644644

645+
// Deprecated: use the function Location()
646+
//
645647
// GetMousePos get the mouse's position return x, y
646648
func GetMousePos() (int, int) {
649+
return Location()
650+
}
651+
652+
// Location get the mouse location position return x, y
653+
func Location() (int, int) {
647654
pos := C.getMousePos()
648655
x := int(pos.x)
649656
y := int(pos.y)
@@ -773,17 +780,17 @@ func Scroll(x, y int, args ...int) {
773780
MilliSleep(MouseSleep + msDelay)
774781
}
775782

776-
// ScrollMouse scroll the mouse to (x, "up")
783+
// ScrollDir scroll the mouse with direction to (x, "up")
777784
// supported: "up", "down", "left", "right"
778785
//
779786
// Examples:
780787
//
781-
// robotgo.ScrollMouse(10, "down")
782-
// robotgo.ScrollMouse(10, "up")
783-
func ScrollMouse(x int, direction ...string) {
788+
// robotgo.ScrollDir(10, "down")
789+
// robotgo.ScrollDir(10, "up")
790+
func ScrollDir(x int, direction ...interface{}) {
784791
d := "down"
785792
if len(direction) > 0 {
786-
d = direction[0]
793+
d = direction[0].(string)
787794
}
788795

789796
if d == "down" {

robotgo_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ func TestDragMouse(t *testing.T) {
6868
}
6969

7070
func TestScrollMouse(t *testing.T) {
71-
ScrollMouse(120, "up")
72-
ScrollMouse(100, "right")
71+
ScrollDir(120, "up")
72+
ScrollDir(100, "right")
7373

7474
Scroll(0, 120)
7575
MilliSleep(100)

0 commit comments

Comments
 (0)