Update Mouse

This commit is contained in:
vCaesar 2016-11-12 22:15:30 +08:00
parent 01962c756b
commit a30a5fd1e3
8 changed files with 44 additions and 7 deletions

View File

@ -79,6 +79,8 @@ import (
func main() {
robotgo.ScrollMouse(10, "up")
robogo.MouseClick("left",true)
robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0)
}
```

View File

@ -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
View File

@ -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>

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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) {

View File

@ -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)
```
###<h3 id="MouseClick">.MouseClick(button, double)</h3>
鼠标点击