From 9412f8be632a8af16e5f07a29bc890193a652882 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Tue, 6 Feb 2018 21:32:39 +0800 Subject: [PATCH] add move smooth return --- mouse/goMouse.h | 7 +++---- mouse/mouse_c.h | 4 ++-- robotgo.go | 14 +++++++++----- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/mouse/goMouse.h b/mouse/goMouse.h index dbdcb12..f83c862 100644 --- a/mouse/goMouse.h +++ b/mouse/goMouse.h @@ -64,15 +64,14 @@ int drag_mouse(size_t x, size_t y){ return 0; } -int move_mouse_smooth(size_t x, size_t y, double lowSpeed, +bool move_mouse_smooth(size_t x, size_t y, double lowSpeed, double highSpeed, int msDelay){ MMPoint point; point = MMPointMake(x, y); - smoothlyMoveMouse(point, lowSpeed, highSpeed); + bool cbool = smoothlyMoveMouse(point, lowSpeed, highSpeed); microsleep(msDelay); - return 0; - + return cbool; } MMPoint get_mouse_pos(){ diff --git a/mouse/mouse_c.h b/mouse/mouse_c.h index e9389bd..429f42d 100644 --- a/mouse/mouse_c.h +++ b/mouse/mouse_c.h @@ -335,8 +335,8 @@ bool smoothlyMoveMouse(MMPoint endPoint, double lowSpeed, double highSpeed) double distance; while ((distance = - crude_hypot((double)pos.x - endPoint.x, (double)pos.y - endPoint.y)) - > 1.0) { + 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(lowSpeed, highSpeed); diff --git a/robotgo.go b/robotgo.go index 8759e58..1230d25 100644 --- a/robotgo.go +++ b/robotgo.go @@ -63,7 +63,7 @@ import ( ) const ( - version string = "v0.48.0.509, Ben Nevis!" + version string = "v0.48.0.510, Ben Nevis!" ) type ( @@ -375,7 +375,7 @@ func Drag(x, y int) { // MoveMouseSmooth move the mouse smooth, // moves mouse to x, y human like, with the mouse button up. -func MoveMouseSmooth(x, y int, args ...interface{}) { +func MoveMouseSmooth(x, y int, args ...interface{}) bool { cx := C.size_t(x) cy := C.size_t(y) @@ -397,12 +397,14 @@ func MoveMouseSmooth(x, y int, args ...interface{}) { high = 3.0 } - C.move_mouse_smooth(cx, cy, low, high, C.int(mouseDelay)) + cbool := C.move_mouse_smooth(cx, cy, low, high, C.int(mouseDelay)) + + return bool(cbool) } // MoveSmooth move the mouse smooth, // moves mouse to x, y human like, with the mouse button up. -func MoveSmooth(x, y int, args ...interface{}) { +func MoveSmooth(x, y int, args ...interface{}) bool { cx := C.size_t(x) cy := C.size_t(y) @@ -424,7 +426,9 @@ func MoveSmooth(x, y int, args ...interface{}) { high = 3.0 } - C.move_mouse_smooth(cx, cy, low, high, C.int(mouseDelay)) + cbool := C.move_mouse_smooth(cx, cy, low, high, C.int(mouseDelay)) + + return bool(cbool) } // GetMousePos get mouse portion