xxxxxxxxxx
import pyautogui
# Capture the screen
screenshot = pyautogui.screenshot()
# Specify the desired file name and save the screenshot
screenshot.save('screenshot.png')
# Optional: Open the screenshot file
screenshot.show()
xxxxxxxxxx
import pyautogui
# Take screenshot of the entire screen
screenshot = pyautogui.screenshot()
screenshot.save('screenshot.png')
xxxxxxxxxx
import subprocess
# Take screenshot of the entire screen
subprocess.run("screencapture screenshot.png")
# Take screenshot of a specific window
window_id = "WINDOW_ID" # Replace with the actual window ID
subprocess.run(f"screencapture -l {window_id} screenshot.png")
# Take screenshot of a selected region
subprocess.run("screencapture -i screenshot.png")