go-vgo / robotgo

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

Move mouse to wrong location on multiple monitor #631

Open vietanhtwdk opened 6 months ago

vietanhtwdk commented 6 months ago
package main

import (
    "fmt"

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

func main() {
    robotgo.Move(0, 0)
    fmt.Println(robotgo.Location())
}

Description

2560x1600 on left side 3440x1440 set as main display

image ...

andrewfstratton commented 6 months ago

Possibly related/relevant:

When you get the screen width and height - this is of all the monitors (the workspace?), e.g.

        width, height := robotgo.GetScreenSize()
        fmt.Println("width = ", width, "height = ", height)

Gives - for two monitors - main being 1920x1200 and second (on right) being 1920x1080

N.B. Beware that (for me) the main display gives incorrect X/Y values if scaling is on :(

Currently any mouse relative movement on the second display has some very strange behaviour where the mouse jumps off to the extremes of the display/s, this seems to only happen when the coordinates are out of the main display range.

Question/possible solution:

Best wishes - Andy

andrewfstratton commented 6 months ago

Aha - the wierd relative movement behaviour seems to be down to scaling

This can be repeated (on windows) by changing the scaling to (say) 125%. The relative movement seems to add (not verified) the difference between the actual pixel width of all the displays, and the scaled pixels which shifts the position over every time a relative move is made.

So - there's something about scaling that isn't consistent - the workspace height/width calculation ignores scaling. possibly using the primary width as unscaled pixels but then applies the new coordinates with scaling being used, so shifts across a number of pixels every time.