diff --git a/README.md b/README.md
index aaa5f47..3d28496 100644
--- a/README.md
+++ b/README.md
@@ -79,6 +79,8 @@ import (
func main() {
robotgo.ScrollMouse(10, "up")
+ robogo.MouseClick("left",true)
+ robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0)
}
```
diff --git a/README_zh.md b/README_zh.md
index 32ecef6..41667c5 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -76,6 +76,8 @@ import (
func main() {
robotgo.ScrollMouse(10, "up")
+ robogo.MouseClick("left",true)
+ robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0)
}
```
diff --git a/doc.md b/doc.md
index 17676c8..c1e1940 100644
--- a/doc.md
+++ b/doc.md
@@ -130,6 +130,14 @@ robotgo.MoveMouse(100, 100)
####Arguments:
x,y
+ lowspeed,highspeed
+
+####Examples:
+
+```Go
+ robotgo.MoveMouseSmooth(100, 200)
+ robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0)
+```
###
.MouseClick(button, double)
diff --git a/mouse/goMouse.h b/mouse/goMouse.h
index afba2d1..c21527b 100644
--- a/mouse/goMouse.h
+++ b/mouse/goMouse.h
@@ -63,10 +63,10 @@ int aDragMouse(size_t x, size_t y){
return 0;
}
-int aMoveMouseSmooth(size_t x, size_t y){
+int aMoveMouseSmooth(size_t x, size_t y,double lowSpeed,double highSpeed){
MMPoint point;
point = MMPointMake(x, y);
- smoothlyMoveMouse(point);
+ smoothlyMoveMouse(point, lowSpeed, highSpeed);
microsleep(mouseDelay);
return 0;
diff --git a/mouse/mouse.h b/mouse/mouse.h
index a32507d..6f7d904 100644
--- a/mouse/mouse.h
+++ b/mouse/mouse.h
@@ -76,7 +76,8 @@ void dragMouse(MMPoint point, const MMMouseButton button);
*
* Returns false if unsuccessful (i.e. a point was hit that is outside of the
* screen boundaries), or true if successful. */
-bool smoothlyMoveMouse(MMPoint point);
+bool smoothlyMoveMouse(MMPoint endPoint, double lowSpeed, double highSpeed);
+// bool smoothlyMoveMouse(MMPoint point);
/* Returns the coordinates of the mouse on the current screen. */
MMPoint getMousePos(void);
diff --git a/mouse/mouse_c.h b/mouse/mouse_c.h
index 4c62daa..bf1273e 100644
--- a/mouse/mouse_c.h
+++ b/mouse/mouse_c.h
@@ -327,7 +327,7 @@ static double crude_hypot(double x, double y)
return ((M_SQRT2 - 1.0) * small) + big;
}
-bool smoothlyMoveMouse(MMPoint endPoint)
+bool smoothlyMoveMouse(MMPoint endPoint, double lowSpeed, double highSpeed)
{
MMPoint pos = getMousePos();
MMSize screenSize = getMainDisplaySize();
@@ -336,7 +336,8 @@ bool smoothlyMoveMouse(MMPoint endPoint)
while ((distance = crude_hypot((double)pos.x - endPoint.x,
(double)pos.y - endPoint.y)) > 1.0) {
- double gravity = DEADBEEF_UNIFORM(5.0, 500.0);
+ // double gravity = DEADBEEF_UNIFORM(5.0, 500.0);
+ double gravity = DEADBEEF_UNIFORM(lowSpeed, highSpeed);
double veloDistance;
velo_x += (gravity * ((double)endPoint.x - pos.x)) / distance;
velo_y += (gravity * ((double)endPoint.y - pos.y)) / distance;
diff --git a/robotgo.go b/robotgo.go
index 04ad138..8a35f65 100644
--- a/robotgo.go
+++ b/robotgo.go
@@ -153,10 +153,25 @@ func DragMouse(x, y int) {
C.aDragMouse(cx, cy)
}
-func MoveMouseSmooth(x, y int) {
+func MoveMouseSmooth(x, y int, args ...float64) {
cx := C.size_t(x)
cy := C.size_t(y)
- C.aMoveMouseSmooth(cx, cy)
+
+ var (
+ low C.double
+ high C.double
+ )
+
+ Try(func() {
+ low = C.double(args[2])
+ high = C.double(args[3])
+ }, func(e interface{}) {
+ // Println("err:::", e)
+ low = 5.0
+ high = 500.0
+ })
+
+ C.aMoveMouseSmooth(cx, cy, low, high)
}
func GetMousePos() (int, int) {
diff --git a/zh_doc.md b/zh_doc.md
index e8eb7ad..df79c1c 100644
--- a/zh_doc.md
+++ b/zh_doc.md
@@ -137,6 +137,14 @@ robotgo.MoveMouse(100, 100)
####参数:
x,y
+ lowspeed,highspeed
+
+####例子:
+
+```Go
+ robotgo.MoveMouseSmooth(100, 200)
+ robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0)
+```
###.MouseClick(button, double)
鼠标点击