mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-02 15:13:55 +00:00
update move mouse smooth and update mouse c name
This commit is contained in:
parent
b8413f7bd4
commit
d238461afa
@ -39,7 +39,7 @@ int mouseDelay = 10;
|
|||||||
// return 0;
|
// return 0;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
int aMoveMouse(size_t x, size_t y){
|
int move_mouse(size_t x, size_t y){
|
||||||
MMPoint point;
|
MMPoint point;
|
||||||
//int x = 103;
|
//int x = 103;
|
||||||
//int y = 104;
|
//int y = 104;
|
||||||
@ -49,7 +49,7 @@ int aMoveMouse(size_t x, size_t y){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int aDragMouse(size_t x, size_t y){
|
int drag_mouse(size_t x, size_t y){
|
||||||
// const size_t x = 10;
|
// const size_t x = 10;
|
||||||
// const size_t y = 20;
|
// const size_t y = 20;
|
||||||
MMMouseButton button = LEFT_BUTTON;
|
MMMouseButton button = LEFT_BUTTON;
|
||||||
@ -63,17 +63,18 @@ int aDragMouse(size_t x, size_t y){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int aMoveMouseSmooth(size_t x, size_t y, double lowSpeed, double highSpeed){
|
int move_mouse_smooth(size_t x, size_t y, double lowSpeed,
|
||||||
|
double highSpeed, int msDelay){
|
||||||
MMPoint point;
|
MMPoint point;
|
||||||
point = MMPointMake(x, y);
|
point = MMPointMake(x, y);
|
||||||
smoothlyMoveMouse(point, lowSpeed, highSpeed);
|
smoothlyMoveMouse(point, lowSpeed, highSpeed);
|
||||||
microsleep(mouseDelay);
|
microsleep(msDelay);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MMPoint aGetMousePos(){
|
MMPoint get_mousePos(){
|
||||||
MMPoint pos = getMousePos();
|
MMPoint pos = getMousePos();
|
||||||
|
|
||||||
// Return object with .x and .y.
|
// Return object with .x and .y.
|
||||||
@ -81,7 +82,7 @@ MMPoint aGetMousePos(){
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
int aMouseClick(MMMouseButton button, bool doubleC){
|
int mouse_click(MMMouseButton button, bool doubleC){
|
||||||
// MMMouseButton button = LEFT_BUTTON;
|
// MMMouseButton button = LEFT_BUTTON;
|
||||||
// bool doubleC = false;
|
// bool doubleC = false;
|
||||||
|
|
||||||
@ -96,7 +97,7 @@ int aMouseClick(MMMouseButton button, bool doubleC){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int aMouseToggle(char* d, MMMouseButton button){
|
int mouse_toggle(char* d, MMMouseButton button){
|
||||||
// MMMouseButton button = LEFT_BUTTON;
|
// MMMouseButton button = LEFT_BUTTON;
|
||||||
bool down = false;
|
bool down = false;
|
||||||
if (strcmp(d, "down") == 0){
|
if (strcmp(d, "down") == 0){
|
||||||
@ -112,14 +113,14 @@ int aMouseToggle(char* d, MMMouseButton button){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int aSetMouseDelay(size_t val){
|
int set_mouseDelay(size_t val){
|
||||||
// int val = 10;
|
// int val = 10;
|
||||||
mouseDelay = val;
|
mouseDelay = val;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int aScrollMouse(size_t scrollMagnitude, char *s){
|
int scroll_mouse(size_t scrollMagnitude, char *s){
|
||||||
// int scrollMagnitude = 20;
|
// int scrollMagnitude = 20;
|
||||||
|
|
||||||
MMMouseWheelDirection scrollDirection;
|
MMMouseWheelDirection scrollDirection;
|
||||||
|
52
robotgo.go
52
robotgo.go
@ -62,7 +62,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
version string = "v0.47.0.461, Mount Cook!"
|
version string = "v0.47.0.466, Mount Cook!"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@ -343,75 +343,85 @@ func MoveMouse(x, y int) {
|
|||||||
// C.size_t int
|
// C.size_t int
|
||||||
cx := C.size_t(x)
|
cx := C.size_t(x)
|
||||||
cy := C.size_t(y)
|
cy := C.size_t(y)
|
||||||
C.aMoveMouse(cx, cy)
|
C.move_mouse(cx, cy)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move move the mouse
|
// Move move the mouse
|
||||||
func Move(x, y int) {
|
func Move(x, y int) {
|
||||||
cx := C.size_t(x)
|
cx := C.size_t(x)
|
||||||
cy := C.size_t(y)
|
cy := C.size_t(y)
|
||||||
C.aMoveMouse(cx, cy)
|
C.move_mouse(cx, cy)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DragMouse drag the mouse
|
// DragMouse drag the mouse
|
||||||
func DragMouse(x, y int) {
|
func DragMouse(x, y int) {
|
||||||
cx := C.size_t(x)
|
cx := C.size_t(x)
|
||||||
cy := C.size_t(y)
|
cy := C.size_t(y)
|
||||||
C.aDragMouse(cx, cy)
|
C.drag_mouse(cx, cy)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drag drag the mouse
|
// Drag drag the mouse
|
||||||
func Drag(x, y int) {
|
func Drag(x, y int) {
|
||||||
cx := C.size_t(x)
|
cx := C.size_t(x)
|
||||||
cy := C.size_t(y)
|
cy := C.size_t(y)
|
||||||
C.aDragMouse(cx, cy)
|
C.drag_mouse(cx, cy)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MoveMouseSmooth move the mouse smooth
|
// MoveMouseSmooth move the mouse smooth
|
||||||
func MoveMouseSmooth(x, y int, args ...float64) {
|
func MoveMouseSmooth(x, y int, args ...interface{}) {
|
||||||
cx := C.size_t(x)
|
cx := C.size_t(x)
|
||||||
cy := C.size_t(y)
|
cy := C.size_t(y)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
mouseDelay = 10
|
||||||
low C.double
|
low C.double
|
||||||
high C.double
|
high C.double
|
||||||
)
|
)
|
||||||
|
|
||||||
if len(args) > 1 {
|
if len(args) > 2 {
|
||||||
low = C.double(args[0])
|
mouseDelay = args[2].(int)
|
||||||
high = C.double(args[1])
|
}
|
||||||
|
|
||||||
|
if len(args) > 0 {
|
||||||
|
low = C.double(args[0].(float64))
|
||||||
|
high = C.double(args[1].(float64))
|
||||||
} else {
|
} else {
|
||||||
low = 5.0
|
low = 5.0
|
||||||
high = 500.0
|
high = 500.0
|
||||||
}
|
}
|
||||||
|
|
||||||
C.aMoveMouseSmooth(cx, cy, low, high)
|
C.move_mouse_smooth(cx, cy, low, high, C.int(mouseDelay))
|
||||||
}
|
}
|
||||||
|
|
||||||
// MoveSmooth move the mouse smooth
|
// MoveSmooth move the mouse smooth
|
||||||
func MoveSmooth(x, y int, args ...float64) {
|
func MoveSmooth(x, y int, args ...interface{}) {
|
||||||
cx := C.size_t(x)
|
cx := C.size_t(x)
|
||||||
cy := C.size_t(y)
|
cy := C.size_t(y)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
mouseDelay = 10
|
||||||
low C.double
|
low C.double
|
||||||
high C.double
|
high C.double
|
||||||
)
|
)
|
||||||
|
|
||||||
if len(args) > 1 {
|
if len(args) > 2 {
|
||||||
low = C.double(args[0])
|
mouseDelay = args[2].(int)
|
||||||
high = C.double(args[1])
|
}
|
||||||
|
|
||||||
|
if len(args) > 0 {
|
||||||
|
low = C.double(args[0].(float64))
|
||||||
|
high = C.double(args[1].(float64))
|
||||||
} else {
|
} else {
|
||||||
low = 5.0
|
low = 5.0
|
||||||
high = 500.0
|
high = 500.0
|
||||||
}
|
}
|
||||||
|
|
||||||
C.aMoveMouseSmooth(cx, cy, low, high)
|
C.move_mouse_smooth(cx, cy, low, high, C.int(mouseDelay))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMousePos get mouse portion
|
// GetMousePos get mouse portion
|
||||||
func GetMousePos() (int, int) {
|
func GetMousePos() (int, int) {
|
||||||
pos := C.aGetMousePos()
|
pos := C.get_mousePos()
|
||||||
// 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)
|
||||||
@ -444,7 +454,7 @@ func MouseClick(args ...interface{}) {
|
|||||||
double = false
|
double = false
|
||||||
})
|
})
|
||||||
|
|
||||||
C.aMouseClick(button, double)
|
C.mouse_click(button, double)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Click click the mouse
|
// Click click the mouse
|
||||||
@ -472,7 +482,7 @@ func Click(args ...interface{}) {
|
|||||||
double = false
|
double = false
|
||||||
})
|
})
|
||||||
|
|
||||||
C.aMouseClick(button, double)
|
C.mouse_click(button, double)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MoveClick move and click the mouse
|
// MoveClick move and click the mouse
|
||||||
@ -502,21 +512,21 @@ func MouseToggle(args ...interface{}) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
down := C.CString(args[0].(string))
|
down := C.CString(args[0].(string))
|
||||||
C.aMouseToggle(down, button)
|
C.mouse_toggle(down, button)
|
||||||
defer C.free(unsafe.Pointer(down))
|
defer C.free(unsafe.Pointer(down))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetMouseDelay set mouse delay
|
// SetMouseDelay set mouse delay
|
||||||
func SetMouseDelay(x int) {
|
func SetMouseDelay(x int) {
|
||||||
cx := C.size_t(x)
|
cx := C.size_t(x)
|
||||||
C.aSetMouseDelay(cx)
|
C.set_mouseDelay(cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScrollMouse scroll the mouse
|
// ScrollMouse scroll the mouse
|
||||||
func ScrollMouse(x int, y string) {
|
func ScrollMouse(x int, y string) {
|
||||||
cx := C.size_t(x)
|
cx := C.size_t(x)
|
||||||
z := C.CString(y)
|
z := C.CString(y)
|
||||||
C.aScrollMouse(cx, z)
|
C.scroll_mouse(cx, z)
|
||||||
defer C.free(unsafe.Pointer(z))
|
defer C.free(unsafe.Pointer(z))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user