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