Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Pyhon DirectInput鼠标相对移动行为不符合预期_Python_Python 3.x_Mouse_Directinput - Fatal编程技术网

Python Pyhon DirectInput鼠标相对移动行为不符合预期

Python Pyhon DirectInput鼠标相对移动行为不符合预期,python,python-3.x,mouse,directinput,Python,Python 3.x,Mouse,Directinput,我找到了通过DirectInput模拟鼠标移动的解决方案。重点是使用python脚本在3D游戏中导航角色。这意味着必须使用相对鼠标移动 一切都正常,但当我尝试计算游戏中x个单位(在Mousemovoint函数中)和角色旋转角度(角度)之间的关系时,我发现算术运算不起作用 例如: 当我向左移动鼠标2 x 200个单位时1 x 400个单位时 2x200

我找到了通过DirectInput模拟鼠标移动的解决方案。重点是使用python脚本在3D游戏中导航角色。这意味着必须使用相对鼠标移动

一切都正常,但当我尝试计算游戏中x个单位(在Mousemovoint函数中)和角色旋转角度(角度)之间的关系时,我发现算术运算不起作用

例如:

当我向左移动鼠标2 x 200个单位时1 x 400个单位时

2x200<1x400

如果我尝试设置运动动画(例如,将运动划分为50步),情况会变得更糟

我是做错了什么,还是这是正常的行为?如果这是正常行为,是否有任何方法可以计算正确的传递到MouseMove to()的单元数


好的。。。所以问题是Windows的“增强指针精度”设置,简而言之,它使小(慢)鼠标移动更小,大(快)鼠标移动更大

关闭后,一切正常


有关此windows“功能”的详细信息,请在此运行以下代码

def MouseMoveTo(x, y):
        x = 1 + int(x * 65536./1920.)#1920 width of your desktop
        y = 1 + int(y * 65536./1080.)#1080 height of your desktop
        extra = ctypes.c_ulong(0)
        ii_ = Input_I()
        ii_.mi =  MouseInput(x,y,0, (0x0001 | 0x8000), 0, ctypes.pointer(extra) )
        x = Input( ctypes.c_ulong(0), ii_ )
        SendInput(1, ctypes.pointer(x), ctypes.sizeof(x))
def MouseMoveTo(x, y):
        x = 1 + int(x * 65536./1920.)#1920 width of your desktop
        y = 1 + int(y * 65536./1080.)#1080 height of your desktop
        extra = ctypes.c_ulong(0)
        ii_ = Input_I()
        ii_.mi =  MouseInput(x,y,0, (0x0001 | 0x8000), 0, ctypes.pointer(extra) )
        x = Input( ctypes.c_ulong(0), ii_ )
        SendInput(1, ctypes.pointer(x), ctypes.sizeof(x))