Skip to content

Commit 6daec24

Browse files
committed
Update godoc
1 parent dee7a28 commit 6daec24

File tree

1 file changed

+50
-16
lines changed

1 file changed

+50
-16
lines changed

robotgo.go

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,10 @@ func MoveMouse(x, y int) {
437437
}
438438

439439
// Move move the mouse to (x, y)
440+
//
441+
// Examples:
442+
// robotgo.MouseSleep = 100 // 100 millisecond
443+
// robotgo.Move(10, 10)
440444
func Move(x, y int) {
441445
cx := C.int32_t(x)
442446
cy := C.int32_t(y)
@@ -471,6 +475,9 @@ func Drag(x, y int, args ...string) {
471475
}
472476

473477
// DragSmooth drag the mouse like smooth to (x, y)
478+
//
479+
// Examples:
480+
// robotgo.DragSmooth(10, 10)
474481
func DragSmooth(x, y int, args ...interface{}) {
475482
Toggle("left")
476483
MilliSleep(50)
@@ -488,6 +495,10 @@ func MoveMouseSmooth(x, y int, args ...interface{}) bool {
488495
// moves mouse to x, y human like, with the mouse button up.
489496
//
490497
// robotgo.MoveSmooth(x, y int, low, high float64, mouseDelay int)
498+
//
499+
// Examples:
500+
// robotgo.MoveSmooth(10, 10)
501+
// robotgo.MoveSmooth(10, 10, 1.0, 2.0)
491502
func MoveSmooth(x, y int, args ...interface{}) bool {
492503
cx := C.int32_t(x)
493504
cy := C.int32_t(y)
@@ -516,7 +527,7 @@ func MoveSmooth(x, y int, args ...interface{}) bool {
516527
return bool(cbool)
517528
}
518529

519-
// MoveArgs move mouse relative args
530+
// MoveArgs get the mouse relative args
520531
func MoveArgs(x, y int) (int, int) {
521532
mx, my := GetMousePos()
522533
mx = mx + x
@@ -536,7 +547,7 @@ func MoveSmoothRelative(x, y int, args ...interface{}) {
536547
MoveSmooth(mx, my, args...)
537548
}
538549

539-
// GetMousePos get mouse's portion
550+
// GetMousePos get mouse's portion return x, y
540551
func GetMousePos() (int, int) {
541552
pos := C.get_mouse_pos()
542553

@@ -553,9 +564,14 @@ func MouseClick(args ...interface{}) {
553564
Click(args...)
554565
}
555566

556-
// Click click the mouse
567+
// Click click the mouse button
557568
//
558569
// robotgo.Click(button string, double bool)
570+
//
571+
// Examples:
572+
// robotgo.Click() // default is left button
573+
// robotgo.Click("right")
574+
// robotgo.Click("wheelLeft")
559575
func Click(args ...interface{}) {
560576
var (
561577
button C.MMMouseButton = C.LEFT_BUTTON
@@ -588,12 +604,12 @@ func MovesClick(x, y int, args ...interface{}) {
588604
MouseClick(args...)
589605
}
590606

591-
// Toggle toggle the mose, support: "left", "center", "right",
607+
// Toggle toggle the mouse, support button: "left", "center", "right",
592608
// "wheelDown", "wheelUp", "wheelLeft", "wheelRight"
593609
//
594610
// Examples:
595-
// robotgo.Toggle("left", "up")
596-
// robotgo.Toggle("left") // default is down
611+
// robotgo.Toggle("left") // default is down
612+
// robotgo.Toggle("left", "up")
597613
func Toggle(key ...string) int {
598614
var button C.MMMouseButton = C.LEFT_BUTTON
599615
if len(key) > 0 {
@@ -611,6 +627,10 @@ func Toggle(key ...string) int {
611627
}
612628

613629
// MouseToggle toggle the mouse
630+
//
631+
// Examples:
632+
// robotgo.MouseToggle("down", "right")
633+
// robotgo.MouseToggle("up", "right")
614634
func MouseToggle(togKey string, args ...interface{}) int {
615635
var button C.MMMouseButton = C.LEFT_BUTTON
616636

@@ -626,7 +646,11 @@ func MouseToggle(togKey string, args ...interface{}) int {
626646
return int(i)
627647
}
628648

629-
// ScrollMouse scroll the mouse
649+
// ScrollMouse scroll the mouse to (x, "up")
650+
//
651+
// Examples:
652+
// robotgo.ScrollMouse(10, "down")
653+
// robotgo.ScrollMouse(10, "up")
630654
func ScrollMouse(x int, direction string) {
631655
cx := C.size_t(x)
632656
cy := C.CString(direction)
@@ -639,6 +663,9 @@ func ScrollMouse(x int, direction string) {
639663
// Scroll scroll the mouse to (x, y)
640664
//
641665
// robotgo.Scroll(x, y, msDelay int)
666+
//
667+
// Examples:
668+
// robotgo.Scroll(10, 10)
642669
func Scroll(x, y int, args ...int) {
643670
var msDelay = 10
644671
if len(args) > 0 {
@@ -654,6 +681,9 @@ func Scroll(x, y int, args ...int) {
654681
}
655682

656683
// ScrollRelative scroll mouse with relative
684+
//
685+
// Examples:
686+
// robotgo.ScrollRelative(10, 10)
657687
func ScrollRelative(x, y int, args ...int) {
658688
mx, my := MoveArgs(x, y)
659689
Scroll(mx, my, args...)
@@ -681,11 +711,12 @@ func SetMouseDelay(delay int) {
681711
// https://github.com/go-vgo/robotgo/blob/master/docs/keys.md
682712
//
683713
// Examples:
684-
// robotgo.KeyTap("a")
685-
// robotgo.KeyTap("i", "alt", "command")
714+
// robotgo.KeySleep = 100 // 100 millisecond
715+
// robotgo.KeyTap("a")
716+
// robotgo.KeyTap("i", "alt", "command")
686717
//
687-
// arr := []string{"alt", "command"}
688-
// robotgo.KeyTap("i", arr)
718+
// arr := []string{"alt", "command"}
719+
// robotgo.KeyTap("i", arr)
689720
//
690721
func KeyTap(tapKey string, args ...interface{}) string {
691722
var (
@@ -781,10 +812,10 @@ func KeyTap(tapKey string, args ...interface{}) string {
781812
// https://github.com/go-vgo/robotgo/blob/master/docs/keys.md
782813
//
783814
// Examples:
784-
// robotgo.KeyToggle("a")
785-
// robotgo.KeyToggle("a", "up")
815+
// robotgo.KeyToggle("a")
816+
// robotgo.KeyToggle("a", "up")
786817
//
787-
// robotgo.KeyToggle("a", "up", "alt", "cmd")
818+
// robotgo.KeyToggle("a", "up", "alt", "cmd")
788819
//
789820
func KeyToggle(key string, args ...string) string {
790821
if len(args) <= 0 {
@@ -924,7 +955,7 @@ func inputUTF(str string) {
924955
// robotgo.TypeStr(string: The string to send, float64: microsleep time, x11 option)
925956
//
926957
// Examples:
927-
// robotgo.TypeStr("abc@123, hi, こんにちは")
958+
// robotgo.TypeStr("abc@123, hi, こんにちは")
928959
//
929960
func TypeStr(str string, args ...float64) {
930961
var tm, tm1 = 0.0, 7.0
@@ -1252,7 +1283,10 @@ func internalActive(pid int32, hwnd int) {
12521283
// C.active_PID(C.uintptr(pid), C.uintptr(hwnd))
12531284
// }
12541285

1255-
// ActiveName active window by name
1286+
// ActiveName active the window by name
1287+
//
1288+
// Examples:
1289+
// robotgo.ActiveName("chrome")
12561290
func ActiveName(name string) error {
12571291
pids, err := FindIds(name)
12581292
if err == nil && len(pids) > 0 {

0 commit comments

Comments
 (0)