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

问题描述 投票:0回答:1

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

没有绝对的鼠标事件在游戏中起作用。唯一对我有用的是]

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

此功能将鼠标相对移动到鼠标的当前位置,但是我不知道如何将其移动到特定像素。

python python-3.x mouseevent
1个回答
1
投票

然后尝试这种解决方法:

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)
© www.soinside.com 2019 - 2024. All rights reserved.