How to change the mouse movement speed with win32api (mouseeventf_move)

Question:

So I basically have a python script set up that moves the mouse in a game to specific x and y coordinates, my question now is how can I make it so the mouse is moving slower, yet still smooth from point a to point b? I tried the sleep command but that just makes it not move smooth rather very robotic. My code:

if keyboard.is_pressed("Alt"):  
              win32api.mouse_event(win32con.MOUSEEVENTF_MOVE, int(x), int(y), 0, 0)
              time.sleep(.02)  
Asked By: JorgTV

||

Answers:

I just found out how to do it! You just have to call the WinAPI for calling the mouse and multiply it by the smoothing value. The higher the smoothing value the faster it goes. It looks something like this:

win32api.mouse_event(win32con.MOUSEEVENTF_MOVE, int(x) * smoothing, int(y) * smoothing, 0, 0)
Answered By: JorgTV
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.