mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 14:43:55 +00:00
add move smooth return
This commit is contained in:
parent
1b840c8102
commit
9412f8be63
@ -64,15 +64,14 @@ int drag_mouse(size_t x, size_t y){
|
|||||||
return 0;
|
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){
|
double highSpeed, int msDelay){
|
||||||
MMPoint point;
|
MMPoint point;
|
||||||
point = MMPointMake(x, y);
|
point = MMPointMake(x, y);
|
||||||
smoothlyMoveMouse(point, lowSpeed, highSpeed);
|
bool cbool = smoothlyMoveMouse(point, lowSpeed, highSpeed);
|
||||||
microsleep(msDelay);
|
microsleep(msDelay);
|
||||||
|
|
||||||
return 0;
|
return cbool;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MMPoint get_mouse_pos(){
|
MMPoint get_mouse_pos(){
|
||||||
|
@ -335,8 +335,8 @@ bool smoothlyMoveMouse(MMPoint endPoint, double lowSpeed, double highSpeed)
|
|||||||
double distance;
|
double distance;
|
||||||
|
|
||||||
while ((distance =
|
while ((distance =
|
||||||
crude_hypot((double)pos.x - endPoint.x, (double)pos.y - endPoint.y))
|
crude_hypot((double)pos.x - endPoint.x, (double)pos.y - endPoint.y)
|
||||||
> 1.0) {
|
) > 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 gravity = DEADBEEF_UNIFORM(lowSpeed, highSpeed);
|
||||||
|
14
robotgo.go
14
robotgo.go
@ -63,7 +63,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
version string = "v0.48.0.509, Ben Nevis!"
|
version string = "v0.48.0.510, Ben Nevis!"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@ -375,7 +375,7 @@ func Drag(x, y int) {
|
|||||||
|
|
||||||
// MoveMouseSmooth move the mouse smooth,
|
// MoveMouseSmooth move the mouse smooth,
|
||||||
// moves mouse to x, y human like, with the mouse button up.
|
// 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)
|
cx := C.size_t(x)
|
||||||
cy := C.size_t(y)
|
cy := C.size_t(y)
|
||||||
|
|
||||||
@ -397,12 +397,14 @@ func MoveMouseSmooth(x, y int, args ...interface{}) {
|
|||||||
high = 3.0
|
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,
|
// MoveSmooth move the mouse smooth,
|
||||||
// moves mouse to x, y human like, with the mouse button up.
|
// 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)
|
cx := C.size_t(x)
|
||||||
cy := C.size_t(y)
|
cy := C.size_t(y)
|
||||||
|
|
||||||
@ -424,7 +426,9 @@ func MoveSmooth(x, y int, args ...interface{}) {
|
|||||||
high = 3.0
|
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
|
// GetMousePos get mouse portion
|
||||||
|
Loading…
Reference in New Issue
Block a user