From bec66ba51f118f524821ff370d7974b61786bcd2 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Mon, 16 Mar 2020 13:51:46 -0400 Subject: [PATCH] add mouse toggle return and add more test --- robotgo.go | 5 +++-- robotgo_test.go | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/robotgo.go b/robotgo.go index 5d9bd7a..6b6d803 100644 --- a/robotgo.go +++ b/robotgo.go @@ -510,7 +510,7 @@ func MovesClick(x, y int, args ...interface{}) { } // MouseToggle toggle the mouse -func MouseToggle(togKey string, args ...interface{}) { +func MouseToggle(togKey string, args ...interface{}) int { var button C.MMMouseButton = C.LEFT_BUTTON if len(args) > 0 { @@ -518,9 +518,10 @@ func MouseToggle(togKey string, args ...interface{}) { } down := C.CString(togKey) - C.mouse_toggle(down, button) + i := C.mouse_toggle(down, button) C.free(unsafe.Pointer(down)) + return int(i) } // ScrollMouse scroll the mouse diff --git a/robotgo_test.go b/robotgo_test.go index 23c4cec..8e69752 100644 --- a/robotgo_test.go +++ b/robotgo_test.go @@ -97,6 +97,11 @@ func TestMoveSmoothRelative(t *testing.T) { tt.Equal(t, 190, y) } +func TestMouseToggle(t *testing.T) { + e := MouseToggle("up", "right") + tt.Zero(t, e) +} + func TestKey(t *testing.T) { e := KeyTap("v", "cmd") tt.Empty(t, e) @@ -120,6 +125,9 @@ func TestTypeStr(t *testing.T) { e := PasteStr("s") tt.Empty(t, e) + + uc := toUC("s") + tt.Equal(t, "[s]", uc) } func TestKeyCode(t *testing.T) {