Skip to main content

Taking a screenshot

Full Screen

import pyautogui

pyautogui.screenshot("C:\\Users\\Nicholas Goh\\Desktop\\test.png")

Specific areas to screenshot can be specified by using the Region argument

import pyautogui

pyautogui.screenshot("C:\\Users\\Nicholas Goh\\Desktop\\test.png", region=(0, 0, 100, 200))

 

Replace C:\\Users\\Nicholas Goh\\Desktop\\test.png  with your own file path and file name. Double backslash in the file path \\ is required as \ is an escape character

 

Region requires an integer value and signifies in order: Left, Top, Width from Left, Height from Top