Search code examples
pythonpython-3.xpyautogui

Change mouse velocity with pyautogui


I am trying to automate a game using pyautogui but I was trying to change the mouse velocity but I couldn't find a way so is there a way? I mean like to look behind you and thanks in forward.


Solution

  • A modified example from the Automate the boring stuff

    import pyautogui
    for i in range(5, 0, -1):
        pyautogui.moveTo(100, 100, duration=0.10*i)
        pyautogui.moveTo(200, 100, duration=0.10*i)
        pyautogui.moveTo(200, 200, duration=0.10*i)
        pyautogui.moveTo(100, 200, duration=0.10*i)
    

    There is duration parameter in the moveTo() function that you can use to control the speed of the mouse. The unit of duration is seconds.