go-vgo / robotgo

RobotGo, Go Native cross-platform RPA and GUI automation @vcaesar
Apache License 2.0
9.45k stars 859 forks source link

Dragsmooth does not work but Drag does sometimes. #653

Open a13x212 opened 2 months ago

a13x212 commented 2 months ago

import ( "github.com/go-vgo/robotgo" )

func main() {

robotgo.Sleep(2)
var sleep = 500
robotgo.Move(900, 560)
robotgo.MilliSleep(sleep)
robotgo.Toggle("left")
robotgo.MilliSleep(sleep)
// robotgo.Drag(600, 560)
robotgo.DragSmooth(600, 560)
robotgo.MilliSleep(sleep)
robotgo.Toggle("left", "up")

}



## Description
DragSmooth will move the mouse correctly but doesn’t seem like it toggles down. 

Commenting out robotgo.DragSmooth(600, 560) and enabling robotgo.Drag(600, 560) does work correctly. 

Running robotgo.Drag in a for loop only works the first time. 
Underscore76 commented 1 month ago

Just a guess for drag smooth: If you check the DragSmooth function in robotgo.go, it toggles the mouse left and then calls MoveSmooth which creates a mouse move event and not a drag event in mouse/mouse_c.h, which for MacOS will be the wrong event type generated for Quartz (guessing this doesn't matter on other platforms?)