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>>> pyautogui.press('enter') # press the Enter key
2>>> pyautogui.press('f1') # press the F1 key
3>>> pyautogui.press('left') # press the left arrow key
4