xxxxxxxxxx
import pyautogui
# Capture and save the screenshot
pyautogui.screenshot('screenshot.png')
xxxxxxxxxx
import pyautogui
# Take a screenshot of the entire screen
screenshot = pyautogui.screenshot()
screenshot.save('screenshot.png')
# Take a screenshot of a specific region
# Define the region coordinates
x = 100
y = 100
width = 300
height = 200
# Capture the region screenshot
region_screenshot = pyautogui.screenshot(region=(x, y, width, height))
region_screenshot.save('region_screenshot.png')