有没有办法让鼠标在不考虑灵敏度的情况下通用?

问题描述

所以我没有代码,因为它不是编码问题,因为我已经完成了程序并且可以工作,但是我注意到:

在游戏菜单中,鼠标灵敏度无关紧要,因为我将坐标设置为单击/移动,并且由于它与灵敏度无关,所以它工作得很好。 然而, 移动游戏摄像机(角色视图)时,如果我执行例如“向右移动 1000 像素”,这将受到鼠标灵敏度和游戏灵敏度的影响,有没有办法使其在所有分辨率/鼠标灵敏度下都能正常工作?

本质上,我需要能够让我的朋友的“相机”/“角色视图”在使用不同鼠标 DPI 的情况下与我的一样移动

解决方法

不要以相对方式移动,而是移动到显示器的固定点,例如:

import pyautogui
import time

time.sleep(3)

pyautogui.moveTo(100,100)

这会将您的鼠标沿显示器向下 100 像素移动到 100 像素。其他示例:

# To make it drag along the screen
# (x,y,time taken)
pyautogui.moveTo(100,100,5)

# To make it hold while moving
# The 5 slows it
pyautogui.dragTo(100,5)

# To check if the next move pos is on display
# This will return false
pyautogui.onScreen(0,-1)

# To Move only x/y
pyautogui.moveTo(None,500)

尽管 pyautogui 应该只向像素方向移动而与 DPI 无关,所以请附上您的代码。