mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-31 06:13:55 +00:00
Update Mouse
This commit is contained in:
parent
01962c756b
commit
a30a5fd1e3
@ -79,6 +79,8 @@ import (
|
||||
|
||||
func main() {
|
||||
robotgo.ScrollMouse(10, "up")
|
||||
robogo.MouseClick("left",true)
|
||||
robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0)
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -76,6 +76,8 @@ import (
|
||||
|
||||
func main() {
|
||||
robotgo.ScrollMouse(10, "up")
|
||||
robogo.MouseClick("left",true)
|
||||
robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0)
|
||||
}
|
||||
```
|
||||
|
||||
|
8
doc.md
8
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)
|
||||
```
|
||||
|
||||
###<h3 id="MouseClick">.MouseClick(button, double)</h3>
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
19
robotgo.go
19
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user