如何在没有绝对鼠标移动的情况下将鼠标移动到屏幕上的任意位置?

How to move the mouse to any position on the screen, without absolute mouse movements?

我正在尝试在仅支持原始输入的游戏中移动鼠标。如何将鼠标移动到已知点?

None 的绝对鼠标事件在游戏中有效。 唯一对我有用的是这个

windll.user32.mouse_event(1, x, y, 0, 0)

这个函数是将鼠标相对于鼠标当前位置移动,但我不知道如何将其移动到特定像素。

然后尝试这样的解决方法:

MOUSEEVENT_MOVE = 1 # it's better to keep that as variable

def set_mouse_pos(x, y):
    current_x, current_y = win32api.GetCursorPos()
    windll.user32.mouse_event(MOUSEEVENT_MOVE, x - current_x, y - current_y, 0, 0)