robotn / gohook

GoHook, Go global keyboard and mouse listener hook
MIT License
314 stars 44 forks source link

MouseDown after drag, instead of MouseUp #32

Open ldemailly opened 2 years ago

ldemailly commented 2 years ago

(Windows 11) When you hold a mouse button (left == 1 for instance) and move the mouse events look like this:

hook: 0 2022-02-06 01:01:06.8846335 -0800 PST m=+9.886081101 - Event: {Kind: MouseHold, Button: 1, X: 1307, Y: 1232, Clicks: 1}
hook: 0 2022-02-06 01:01:07.6386065 -0800 PST m=+10.640054101 - Event: {Kind: MouseDrag, Button: 0, X: 1307, Y: 1233, Clicks: 0}
[...then a lot more of same... until one releases the button...]
hook: 0 2022-02-06 01:01:08.8920229 -0800 PST m=+11.893470501 - Event: {Kind: MouseDrag, Button: 0, X: 1487, Y: 1260, Clicks: 0}
[..this is the issue:...]
hook: 0 2022-02-06 01:01:09.2928355 -0800 PST m=+12.294283101 - Event: {Kind: MouseDown, Button: 1, X: 1487, Y: 1260, Clicks: 0}
hook: 0 2022-02-06 01:01:09.4931115 -0800 PST m=+12.494559101 - Event: {Kind: MouseMove, Button: 0, X: 1487, Y: 1259, Clicks: 0}

I'm pretty sure it should be MouseUp not MouseDown when one releases a button (like it does for KeyHold->KeyUp)?

Right now I'm working around using MouseDown for release (and I wonder who else) so we'd need to change the version tag once fixed

Thanks Laurent

vcaesar commented 2 years ago

Thx, I will check it.

ldemailly commented 2 years ago

https://github.com/robotn/gohook/blob/d8ecd92ccfc45e7418f71220d1536d47ccdde972/hook/iohook.h#L63-L65 Seem swapped if that's how one is 6 and the other 8 in https://github.com/robotn/gohook/blob/833856fd33f1c6d7f364696b41fc6eddfc9074a3/hook.go#L45-L47

ldemailly commented 2 years ago

(ignore my first MR was on my fork... but see #33 for the simple fix... assuming that doesn't break anything but it works for me, tested using

replace github.com/robotn/gohook => github.com/ldemailly/gohook v0.41.0-pre1 )

ldemailly commented 2 years ago

Gentle ping

SpeedReach commented 2 months ago

how is this not fixed ...

ldemailly commented 2 months ago

you can use my fork it has the fix