mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-06 00:33:55 +00:00
Update Mouse
This commit is contained in:
parent
01962c756b
commit
a30a5fd1e3
@ -79,6 +79,8 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
robotgo.ScrollMouse(10, "up")
|
robotgo.ScrollMouse(10, "up")
|
||||||
|
robogo.MouseClick("left",true)
|
||||||
|
robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -76,6 +76,8 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
robotgo.ScrollMouse(10, "up")
|
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:
|
####Arguments:
|
||||||
|
|
||||||
x,y
|
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>
|
###<h3 id="MouseClick">.MouseClick(button, double)</h3>
|
||||||
|
|
||||||
|
@ -63,10 +63,10 @@ int aDragMouse(size_t x, size_t y){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int aMoveMouseSmooth(size_t x, size_t y){
|
int aMoveMouseSmooth(size_t x, size_t y,double lowSpeed,double highSpeed){
|
||||||
MMPoint point;
|
MMPoint point;
|
||||||
point = MMPointMake(x, y);
|
point = MMPointMake(x, y);
|
||||||
smoothlyMoveMouse(point);
|
smoothlyMoveMouse(point, lowSpeed, highSpeed);
|
||||||
microsleep(mouseDelay);
|
microsleep(mouseDelay);
|
||||||
|
|
||||||
return 0;
|
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
|
* Returns false if unsuccessful (i.e. a point was hit that is outside of the
|
||||||
* screen boundaries), or true if successful. */
|
* 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. */
|
/* Returns the coordinates of the mouse on the current screen. */
|
||||||
MMPoint getMousePos(void);
|
MMPoint getMousePos(void);
|
||||||
|
@ -327,7 +327,7 @@ static double crude_hypot(double x, double y)
|
|||||||
return ((M_SQRT2 - 1.0) * small) + big;
|
return ((M_SQRT2 - 1.0) * small) + big;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool smoothlyMoveMouse(MMPoint endPoint)
|
bool smoothlyMoveMouse(MMPoint endPoint, double lowSpeed, double highSpeed)
|
||||||
{
|
{
|
||||||
MMPoint pos = getMousePos();
|
MMPoint pos = getMousePos();
|
||||||
MMSize screenSize = getMainDisplaySize();
|
MMSize screenSize = getMainDisplaySize();
|
||||||
@ -336,7 +336,8 @@ bool smoothlyMoveMouse(MMPoint endPoint)
|
|||||||
|
|
||||||
while ((distance = crude_hypot((double)pos.x - endPoint.x,
|
while ((distance = crude_hypot((double)pos.x - endPoint.x,
|
||||||
(double)pos.y - endPoint.y)) > 1.0) {
|
(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;
|
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;
|
||||||
|
19
robotgo.go
19
robotgo.go
@ -153,10 +153,25 @@ func DragMouse(x, y int) {
|
|||||||
C.aDragMouse(cx, cy)
|
C.aDragMouse(cx, cy)
|
||||||
}
|
}
|
||||||
|
|
||||||
func MoveMouseSmooth(x, y int) {
|
func MoveMouseSmooth(x, y int, args ...float64) {
|
||||||
cx := C.size_t(x)
|
cx := C.size_t(x)
|
||||||
cy := C.size_t(y)
|
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) {
|
func GetMousePos() (int, int) {
|
||||||
|
@ -137,6 +137,14 @@ robotgo.MoveMouse(100, 100)
|
|||||||
####参数:
|
####参数:
|
||||||
|
|
||||||
x,y
|
x,y
|
||||||
|
lowspeed,highspeed
|
||||||
|
|
||||||
|
####例子:
|
||||||
|
|
||||||
|
```Go
|
||||||
|
robotgo.MoveMouseSmooth(100, 200)
|
||||||
|
robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0)
|
||||||
|
```
|
||||||
|
|
||||||
###<h3 id="MouseClick">.MouseClick(button, double)</h3>
|
###<h3 id="MouseClick">.MouseClick(button, double)</h3>
|
||||||
鼠标点击
|
鼠标点击
|
||||||
|
Loading…
Reference in New Issue
Block a user