As of 2020, you can use mouse:
import mouse
mouse.move("500", "500")
mouse.left_click()
Features
- Global event hook on all mice devices (captures events regardless of
focus).
- Listen and sends mouse events.
- Works with Windows and Linux (requires sudo).
- Pure Python, no C modules to be compiled.
- Zero dependencies. Trivial to install and deploy, just copy the
files.
- Python 2 and 3
- Includes high level API (e.g. record and play).
- Events automatically captured in separate thread, doesn't block main
program.
- Tested and documented.