Search code examples
pythonautomationbotspyautogui

Python Glide mouse across screen


In a code like this:

import pyautogui
pyautogui.click(100,200)

Or

Import pyautogui
pyautogui.moveTo(100,150)
pytautogui.click()

The mouse cursor jumps to the specified location, how can i make the mouse curser glide instead of jumping to stimulate human mouse movement


Solution

  • This is taken directly from the documentation of moveTo:

    Normally the mouse cursor will instantly move to the new coordinates. If you want the mouse to gradually move to the new location, pass a third argument for the duration (in seconds) the movement should take. For example:

    >>> pyautogui.moveTo(100, 200, 2)   # moves mouse to X of 100, Y of 200 over 2 seconds