mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 14:43:55 +00:00
update move smooth fix #96
This commit is contained in:
parent
3c4a887903
commit
1b840c8102
@ -16,7 +16,8 @@ int mouseDelay = 10;
|
|||||||
// int keyboardDelay = 10;
|
// int keyboardDelay = 10;
|
||||||
|
|
||||||
|
|
||||||
// int CheckMouseButton(const char * const b, MMMouseButton * const button){
|
// int CheckMouseButton(const char * const b,
|
||||||
|
// MMMouseButton * const button){
|
||||||
// if (!button) return -1;
|
// if (!button) return -1;
|
||||||
|
|
||||||
// if (strcmp(b, "left") == 0)
|
// if (strcmp(b, "left") == 0)
|
||||||
@ -74,7 +75,7 @@ int move_mouse_smooth(size_t x, size_t y, double lowSpeed,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MMPoint get_mousePos(){
|
MMPoint get_mouse_pos(){
|
||||||
MMPoint pos = getMousePos();
|
MMPoint pos = getMousePos();
|
||||||
|
|
||||||
// Return object with .x and .y.
|
// Return object with .x and .y.
|
||||||
|
@ -334,10 +334,12 @@ bool smoothlyMoveMouse(MMPoint endPoint, double lowSpeed, double highSpeed)
|
|||||||
double velo_x = 0.0, velo_y = 0.0;
|
double velo_x = 0.0, velo_y = 0.0;
|
||||||
double distance;
|
double distance;
|
||||||
|
|
||||||
while ((distance = crude_hypot((double)pos.x - endPoint.x,
|
while ((distance =
|
||||||
(double)pos.y - endPoint.y)) > 1.0) {
|
crude_hypot((double)pos.x - endPoint.x, (double)pos.y - endPoint.y))
|
||||||
// double gravity = DEADBEEF_UNIFORM(5.0, 500.0);
|
> 1.0) {
|
||||||
double gravity = DEADBEEF_UNIFORM(lowSpeed, highSpeed);
|
|
||||||
|
double gravity = DEADBEEF_UNIFORM(5.0, 500.0);
|
||||||
|
// double gravity = DEADBEEF_UNIFORM(lowSpeed, highSpeed);
|
||||||
double veloDistance;
|
double veloDistance;
|
||||||
velo_x += (gravity * ((double)endPoint.x - pos.x)) / distance;
|
velo_x += (gravity * ((double)endPoint.x - pos.x)) / distance;
|
||||||
velo_y += (gravity * ((double)endPoint.y - pos.y)) / distance;
|
velo_y += (gravity * ((double)endPoint.y - pos.y)) / distance;
|
||||||
@ -359,7 +361,8 @@ bool smoothlyMoveMouse(MMPoint endPoint, double lowSpeed, double highSpeed)
|
|||||||
moveMouse(pos);
|
moveMouse(pos);
|
||||||
|
|
||||||
/* Wait 1 - 3 milliseconds. */
|
/* Wait 1 - 3 milliseconds. */
|
||||||
microsleep(DEADBEEF_UNIFORM(1.0, 3.0));
|
microsleep(DEADBEEF_UNIFORM(lowSpeed, highSpeed));
|
||||||
|
// microsleep(DEADBEEF_UNIFORM(1.0, 3.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
12
robotgo.go
12
robotgo.go
@ -63,7 +63,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
version string = "v0.48.0.508, Ben Nevis!"
|
version string = "v0.48.0.509, Ben Nevis!"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@ -393,8 +393,8 @@ func MoveMouseSmooth(x, y int, args ...interface{}) {
|
|||||||
low = C.double(args[0].(float64))
|
low = C.double(args[0].(float64))
|
||||||
high = C.double(args[1].(float64))
|
high = C.double(args[1].(float64))
|
||||||
} else {
|
} else {
|
||||||
low = 5.0
|
low = 1.0
|
||||||
high = 500.0
|
high = 3.0
|
||||||
}
|
}
|
||||||
|
|
||||||
C.move_mouse_smooth(cx, cy, low, high, C.int(mouseDelay))
|
C.move_mouse_smooth(cx, cy, low, high, C.int(mouseDelay))
|
||||||
@ -420,8 +420,8 @@ func MoveSmooth(x, y int, args ...interface{}) {
|
|||||||
low = C.double(args[0].(float64))
|
low = C.double(args[0].(float64))
|
||||||
high = C.double(args[1].(float64))
|
high = C.double(args[1].(float64))
|
||||||
} else {
|
} else {
|
||||||
low = 5.0
|
low = 1.0
|
||||||
high = 500.0
|
high = 3.0
|
||||||
}
|
}
|
||||||
|
|
||||||
C.move_mouse_smooth(cx, cy, low, high, C.int(mouseDelay))
|
C.move_mouse_smooth(cx, cy, low, high, C.int(mouseDelay))
|
||||||
@ -429,7 +429,7 @@ func MoveSmooth(x, y int, args ...interface{}) {
|
|||||||
|
|
||||||
// GetMousePos get mouse portion
|
// GetMousePos get mouse portion
|
||||||
func GetMousePos() (int, int) {
|
func GetMousePos() (int, int) {
|
||||||
pos := C.get_mousePos()
|
pos := C.get_mouse_pos()
|
||||||
// fmt.Println("pos:###", pos, pos.x, pos.y)
|
// fmt.Println("pos:###", pos, pos.x, pos.y)
|
||||||
x := int(pos.x)
|
x := int(pos.x)
|
||||||
y := int(pos.y)
|
y := int(pos.y)
|
||||||
|
Loading…
Reference in New Issue
Block a user