From ad85cfd7923121a6d8b2af01226445535a3eb4e6 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Thu, 27 Dec 2018 12:44:38 -0400 Subject: [PATCH] add drag mouse other button support --- mouse/goMouse.h | 13 +++++++------ robotgo.go | 15 +++++++++++---- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/mouse/goMouse.h b/mouse/goMouse.h index 1560f83..0abacbb 100644 --- a/mouse/goMouse.h +++ b/mouse/goMouse.h @@ -16,8 +16,8 @@ int mouseDelay = 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 (strcmp(b, "left") == 0) { @@ -37,18 +37,19 @@ int mouseDelay = 10; int move_mouse(size_t x, size_t y){ MMPoint point; - //int x = 103; - //int y = 104; + // int x = 103; + // int y = 104; point = MMPointMake(x, y); moveMouse(point); return 0; } -int drag_mouse(size_t x, size_t y){ + +int drag_mouse(size_t x, size_t y, MMMouseButton button){ // const size_t x = 10; // const size_t y = 20; - MMMouseButton button = LEFT_BUTTON; + // MMMouseButton button = LEFT_BUTTON; MMPoint point; point = MMPointMake(x, y); diff --git a/robotgo.go b/robotgo.go index f297592..9a86d53 100644 --- a/robotgo.go +++ b/robotgo.go @@ -353,15 +353,22 @@ func Move(x, y int) { } // DragMouse drag the mouse -func DragMouse(x, y int) { - Drag(x, y) +func DragMouse(x, y int, args ...string) { + Drag(x, y, args...) } // Drag drag the mouse -func Drag(x, y int) { +func Drag(x, y int, args ...string) { + var button C.MMMouseButton = C.LEFT_BUTTON + cx := C.size_t(x) cy := C.size_t(y) - C.drag_mouse(cx, cy) + + if len(args) > 0 { + button = CheckMouse(args[0]) + } + + C.drag_mouse(cx, cy, button) } // MoveMouseSmooth move the mouse smooth,