mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-03 23:53:54 +00:00
Refactoring mouse example code
This commit is contained in:
parent
68ba8e8aaa
commit
124fc3703f
@ -17,31 +17,33 @@ import (
|
|||||||
// "go-vgo/robotgo"
|
// "go-vgo/robotgo"
|
||||||
)
|
)
|
||||||
|
|
||||||
func mouse() {
|
func move() {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
robotgo.Move(100, 200)
|
||||||
// Control the mouse
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// move the mouse to 100, 200
|
// move the mouse to 100, 200
|
||||||
robotgo.MoveMouse(100, 200)
|
robotgo.MoveMouse(100, 200)
|
||||||
|
|
||||||
// click the left mouse button
|
|
||||||
robotgo.MouseClick()
|
|
||||||
// click the right mouse button
|
|
||||||
robotgo.MouseClick("right", false)
|
|
||||||
// double click the left mouse button
|
|
||||||
robotgo.MouseClick("left", true)
|
|
||||||
|
|
||||||
// scrolls the mouse either up
|
|
||||||
robotgo.ScrollMouse(10, "up")
|
|
||||||
robotgo.Scroll(100, 200)
|
|
||||||
// toggles right mouse button
|
|
||||||
robotgo.MouseToggle("down", "right")
|
|
||||||
|
|
||||||
// smooth move the mouse to 100, 200
|
// smooth move the mouse to 100, 200
|
||||||
robotgo.MoveMouseSmooth(100, 200)
|
robotgo.MoveSmooth(100, 200)
|
||||||
robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0)
|
robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0)
|
||||||
|
|
||||||
|
for i := 0; i < 1080; i += 1000 {
|
||||||
|
fmt.Println(i)
|
||||||
|
robotgo.MoveMouse(800, i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func click() {
|
||||||
|
|
||||||
|
// click the left mouse button
|
||||||
|
robotgo.Click()
|
||||||
|
// click the right mouse button
|
||||||
|
robotgo.Click("right", false)
|
||||||
|
// double click the left mouse button
|
||||||
|
robotgo.MouseClick("left", true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func get() {
|
||||||
// gets the mouse coordinates
|
// gets the mouse coordinates
|
||||||
x, y := robotgo.GetMousePos()
|
x, y := robotgo.GetMousePos()
|
||||||
fmt.Println("pos:", x, y)
|
fmt.Println("pos:", x, y)
|
||||||
@ -49,15 +51,32 @@ func mouse() {
|
|||||||
fmt.Println("mouse...", "586")
|
fmt.Println("mouse...", "586")
|
||||||
}
|
}
|
||||||
|
|
||||||
robotgo.MouseToggle("up")
|
|
||||||
robotgo.MoveMouse(x, y)
|
robotgo.MoveMouse(x, y)
|
||||||
robotgo.MoveMouse(100, 200)
|
}
|
||||||
|
|
||||||
for i := 0; i < 1080; i += 1000 {
|
func toggleAndScroll() {
|
||||||
fmt.Println(i)
|
// scrolls the mouse either up
|
||||||
robotgo.MoveMouse(800, i)
|
robotgo.ScrollMouse(10, "up")
|
||||||
}
|
robotgo.Scroll(100, 200)
|
||||||
|
|
||||||
|
// toggles right mouse button
|
||||||
|
robotgo.MouseToggle("down", "right")
|
||||||
|
|
||||||
|
robotgo.MouseToggle("up")
|
||||||
|
}
|
||||||
|
|
||||||
|
func mouse() {
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Control the mouse
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
move()
|
||||||
|
|
||||||
|
click()
|
||||||
|
|
||||||
|
get()
|
||||||
|
|
||||||
|
toggleAndScroll()
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
Loading…
Reference in New Issue
Block a user