我正在尝试在仅支持原始输入的游戏中移动鼠标。如何将鼠标移至已知点?
没有绝对的鼠标事件在游戏中起作用。唯一对我有用的是]
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)