Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mouse Location correct In Windows 11 laptop with a resolution of 2560x1600 #626

Open
byzze opened this issue Dec 3, 2023 · 1 comment
Open

Comments

@byzze
Copy link

byzze commented Dec 3, 2023

Using robotgo on a Windows 11 laptop with a resolution of 2560x1600, obtaining mouse position data is incorrect. However, using the native Windows API allows correct retrieval. Is this a bug or am I using it incorrectly?

// GetCursorPos windowsapi
func GetCursorPos() *win.POINT {
	lpPoint := &win.POINT{}
	win.GetCursorPos(lpPoint)
	return lpPoint

}

func TestMouseClickPos(t *testing.T) {
	hook.Register(hook.MouseDown, []string{}, func(e hook.Event) {
		if e.Button == hook.MouseMap["center"] {
			x, y := robotgo.Location()
			fmt.Printf("Location:[x:%d,y:%d]\n", x, y)
			pos := GetCursorPos()
			fmt.Printf("GetCursorPos[x:%d,y:%d]\n", pos.X, pos.Y)
		}
	})
	s := hook.Start()
	<-hook.Process(s)
}

result:

Location:[x:17,y:28]
GetCursorPos[x:10,y:16]
Location:[x:4478,y:24]
GetCursorPos[x:2559,y:14]
Location:[x:17,y:2705]
GetCursorPos[x:10,y:1546]
Location:[x:4466,y:2735]
GetCursorPos[x:2552,y:1563]
@zzp198
Copy link

zzp198 commented Mar 3, 2024

It depends on your screen zoom rate, the default is 1.25.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants