Skip to content Skip to sidebar Skip to footer

Pyhon Directinput Mouse Relative Moving Act Not As Expected

I found solution to emulate mouse movement by DirectInput. Point is to use python script to navigate character in 3D Game. That means that have to use relative mouse movement. Ever

Solution 1:

Ok ... so problem was Windows "Enhance Pointer Precision" setting, which, in short, makes small (slow) mouse moves even smaller and big (fast) even bigger...

After turning it off, everithing works fine.

More about this windows "feature" here https://www.howtogeek.com/321763/what-is-enhance-pointer-precision-in-windows/

Solution 2:

Just run the below code ...

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))

Post a Comment for "Pyhon Directinput Mouse Relative Moving Act Not As Expected"