1from pynput.mouse import Button, Controller
2
3mouse = Controller()
4
5# Read pointer position
6print('The current pointer position is {0}'.format(mouse.position))
7
8# Set pointer position
9mouse.position = (10, 20)
10print('Now we have moved it to {0}'.format(mouse.position))
11
12# Move pointer relative to current position
13mouse.move(5, -5)
14
15# Press and release
16mouse.press(Button.left)
17mouse.release(Button.left)
18
19# Double click; this is different from pressing and releasing
20# twice on Mac OSX
21mouse.click(Button.left, 2)
22
23# Scroll two steps down
24mouse.scroll(0, 2)