1# Import required modules
2import pyautogui
3import time
4
5# FAILSAFE to FALSE feature is enabled by default
6# so that you can easily stop execution of
7# your pyautogui program by manually moving the
8# mouse to the upper left corner of the screen.
9# Once the mouse is in this location,
10# pyautogui will throw an exception and exit.
11pyautogui.FAILSAFE = False
12
13# We want to run this code for infinite
14# time till we stop it so we use infinite loop now
15while True:
16
17 # time.sleep(t) is used to give a break of
18 # specified time t seconds so that its not
19 # too frequent
20 time.sleep(15)
21
22 # This for loop is used to move the mouse
23 # pointer to 500 pixels in this case(5*100)
24 for i in range(0, 100):
25 pyautogui.moveTo(0, i * 5)
26
27 # This for loop is used to press keyboard keys,
28 # in this case the harmless key shift key is
29 # used. You can change it according to your
30 # requirement. This works with all keys.
31 for i in range(0, 3):
32 pyautogui.press('shift')