mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-30 22:13:54 +00:00
add mouse toggle return and add more test
This commit is contained in:
parent
b5d72b8d18
commit
bec66ba51f
@ -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
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user