I use robotgo for mouse https://pkg.go.dev/github.com/go-vgo/robotgo#section-readme
I’m trying to write a macro for weapons in the game, I’ve done similar in lua before, but there I was working with the api of the mouse software.
In the game the cursor is centered and it is stationary, actually I need to move the cursor -20 by Y for example, I move it smoothly in the direction I want.
However, at the end of the downward movement, it tends to go up to the original position (only in the game).
How do I achieve the desired effect?
I’m testing in Rust game, I don’t know how to simulate this behavior, so I’ll record and attach a gif.
package main
import (
"fmt"
"github.com/go-vgo/robotgo"
hook "github.com/robotn/gohook"
)
func main() {
fmt.Println("--- Please hold MouseLeft---")
hook.Register(hook.MouseHold, nil, func(e hook.Event) {
if e.Button == 1 {
sx, sy := robotgo.GetScreenSize()
robotgo.MouseSleep = 100
robotgo.MoveSmooth(sx/2, sy/2-20, 5.0, 5.0)
}
})
s := hook.Start()
<-hook.Process(s)
}