libuiohook
libuiohook copied to clipboard
Windows Fix Multiple Monitor Mouse Input
Hello! This PR fixes libuiohook's issue with multi-monitor mouse input and movement for Windows.
Very quickly, this is done by converting the low-level mouse hook coordinates that libuiohook returns to be relative to the virtual desktop. It creates an invisible window and listens for the WM_DISPLAYCHANGE event which is sent whenever a monitor changes position or resolution to get the width and height of monitors in relation to the primary monitor. I wrote some notes and examples here if you want to take a look: https://i.imgur.com/z3vKjtm.png
This video shows a modified demo_hook/post_async with the change. This change does not touch dpi stuff, so the calling application should set something like SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE); to handle monitors that are not 100% scale. https://youtu.be/YhrC_oLPtRM
The modified program listens for middle mouse button release and sends a right mouse button down and up at the current mouse coordinates.
This is the sample program: https://gist.github.com/FaithBeam/e90bad32fd2fef0c825cfa9c403f9e7b
Should fix #21.
@FaithBeam this pull request is a little out of date - could you please rebase it on top of the 1.3 branch and resolve conflicts? Also, the original pull request contained a couple more commits - could you add them here as well?
@kwhat did you have a chance to review this pull request?
@TolikPylypchuk if @kwhat expresses interest in this, I'll update the PR.
Ive looked at this vut i still dont understand why its needed.
It's been a while since I last looked at the code, but libuiohook doesn't calculate the correct coordinates for mouse input when multiple monitors are connected on Windows.
One monitor: works Multiple monitors: broken
This PR fixes multiple monitor mouse input for Windows.
Sorry, I accidentally closed this. Reopening.