Im trying to adjust the mouse position to the center of a target window position. To do so, I precalculate the X and Y coordinates that leads to the center position. To perform the mouse move, I am using "SetCursorPos" method from the winapi. My issue is now that the function does not align the x value properly if the cursor is at a lower resolution display (Full HD) and the move has to be performed to a higher resolution display (UHD).
I found out that it performs the action correctly if the Y value is in the range of the window center position Y value.
When the Y value is higher or lower than the allowed Y range (1080), the X of the cursor will be set to the left edge (x = 0) of the target monitor, which means that the cursor is shown now on the correct display with the correct Mouse Y Position but with a wrong Mouse X Position.
我想出了第二次执行 SetCursorPos 方法的想法,这导致了成功。我猜想,该方法第一次会考虑鼠标最初来自的显示器的Y值范围。第二次,光标已经显示在更高分辨率的监视器上,这迫使该方法使用它的 Y 范围。
有人知道如何绕过这个问题吗?