1 >>> import pyautogui
2 >>> screenWidth, screenHeight = pyautogui.size() # Returns two integers, the width and height of the screen. (The primary monitor, in multi-monitor setups.)
3 >>> currentMouseX, currentMouseY = pyautogui.position() # Returns two integers, the x and y of the mouse cursor's current position.
4 >>> pyautogui.moveTo(100, 150) # Move the mouse to the x, y coordinates 100, 150.
5 >>> pyautogui.click() # Click the mouse at its current location.
6 >>> pyautogui.click(200, 220) # Click the mouse at the x, y coordinates 200, 220.
7 >>> pyautogui.move(None, 10) # Move mouse 10 pixels down, that is, move the mouse relative to its current position.
8 >>> pyautogui.doubleClick() # Double click the mouse at the
9 >>> pyautogui.moveTo(500, 500, duration=2, tween=pyautogui.easeInOutQuad) # Use tweening/easing function to move mouse over 2 seconds.
10 >>> pyautogui.write('Hello world!', interval=0.25) # Type with quarter-second pause in between each key.
11 >>> pyautogui.press('esc') # Simulate pressing the Escape key.
12 >>> pyautogui.keyDown('shift')
13 >>> pyautogui.write(['left', 'left', 'left', 'left', 'left', 'left'])
14 >>> pyautogui.keyUp('shift')
15 >>> pyautogui.hotkey('ctrl', 'c')
16
1pip3 install pyautogui
2
3import pyautogui
4screenWidth, screenHeight = pyautogui.size() # Get the size of the primary monitor.
5currentMouseX, currentMouseY = pyautogui.position() # Get the XY position of the mouse.
6pyautogui.moveTo(100, 150) # Move the mouse to XY coordinates.
7pyautogui.moveTo(500, 500, duration=2, tween=pyautogui.easeInOutQuad) # Use tweening/easing function to move mouse over 2 seconds.
8pyautogui.move(0, 10) # Move mouse 10 pixels down from its current position.
9
10pyautogui.click() # Click the mouse.
11pyautogui.click(100, 200) # Move the mouse to XY coordinates and click it.
12pyautogui.click('button.png') # Find where button.png appears on the screen and click it.
13pyautogui.doubleClick() # Double click the mouse.
14
15pyautogui.write('Hello world!', interval=0.25) # type with quarter-second pause in between each key
16pyautogui.press('esc') # Press the Esc key. All key names are in pyautogui.KEY_NAMES
17pyautogui.keyDown('shift') # Press the Shift key down and hold it.
18pyautogui.press(['left', 'left', 'left', 'left']) # Press the left arrow key 4 times.
19pyautogui.keyUp('shift') # Let go of the Shift key.
20pyautogui.hotkey('ctrl', 'c') # Press the Ctrl-C hotkey combination.
21
22pyautogui.alert('This is the message to display.') # Make an alert box appear and pause the program until OK is clicked.
1>>> import pyautogui
2
3>>> screenWidth, screenHeight = pyautogui.size() # Get the size of the primary monitor.
4>>> screenWidth, screenHeight
5(2560, 1440)
6
7>>> currentMouseX, currentMouseY = pyautogui.position() # Get the XY position of the mouse.
8>>> currentMouseX, currentMouseY
9(1314, 345)
10
11>>> pyautogui.moveTo(100, 150) # Move the mouse to XY coordinates.
12
13>>> pyautogui.click() # Click the mouse.
14>>> pyautogui.click(100, 200) # Move the mouse to XY coordinates and click it.
15>>> pyautogui.click('button.png') # Find where button.png appears on the screen and click it.
16
17>>> pyautogui.move(400, 0) # Move the mouse 400 pixels to the right of its current position.
18>>> pyautogui.doubleClick() # Double click the mouse.
19>>> pyautogui.moveTo(500, 500, duration=2, tween=pyautogui.easeInOutQuad) # Use tweening/easing function to move mouse over 2 seconds.
20
21>>> pyautogui.write('Hello world!', interval=0.25) # type with quarter-second pause in between each key
22>>> pyautogui.press('esc') # Press the Esc key. All key names are in pyautogui.KEY_NAMES
23
24>>> with pyautogui.hold('shift'): # Press the Shift key down and hold it.
25 pyautogui.press(['left', 'left', 'left', 'left']) # Press the left arrow key 4 times.
26>>> # Shift key is released automatically.
27
28>>> pyautogui.hotkey('ctrl', 'c') # Press the Ctrl-C hotkey combination.
29
30>>> pyautogui.alert('This is the message to display.') # Make an alert box appear and pause the program until OK is clicked.
31
1import pyautogui
2
3#pyautogui.moveTo(X, Y, Seconds)
4pyautogui.moveTo(100, 100, 2) #Move to X=100, Y=100 over a 2 seconds period