DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk3 min

How to Take Screenshots in Python with PyAutoGUI

Use PyAutoGUI’s screenshot() function to save a full-screen capture or select a rectangle with region=(left, top, width, height).
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use pyautogui.screenshot() to capture the primary screen. Pass a filename to save the image immediately, or save the returned Pillow image later. To capture only part of the screen, pass region=(left, top, width, height).

Install PyAutoGUI and its screenshot dependencies

Install PyAutoGUI in the same Python environment that will run your script. The project’s installation guide gives these commands:

  • Windows: py -m pip install pyautogui
  • macOS and Linux: python3 -m pip install pyautogui

PyAutoGUI’s screenshot documentation says screenshot support requires Pillow. It also identifies macOS’s built-in screencapture command and Linux’s scrot command; its installation guide lists scrot, python3-tk, and python3-dev as Linux packages. These are the requirements named in the documentation; package availability and setup can vary with your operating system and environment, so check your current platform if installation fails.

Capture and save the full screen

This runnable example captures the screen, writes a PNG file, and keeps the returned image available for later processing:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
2.4G Air Remote Control with USB Receiver for Lilux for for Android-TV Box PC Air Rechargeable with Keyboard USB Pointer Pc Controller Voice Gyroscope
  • code memory, no need to set, replace the battery without losing the code, use it directly
  • and
  • The keys are sensitive, sturdy and and easy to operate. Sturdy and fall-resistant, long-term use. Good toughness, high strength, beautiful appearance and not easy to change color
  • Long-distance and all-round free remote control, and comfortable. An analog cursor makes the positioning clearer
  • 2.4G radio frequency technology, 360° remote control, USB plug and for play, 2 keys for learning
import pyautogui

# Capture the screen and save it as a PNG.
image = pyautogui.screenshot("screenshot.png")

print(f"Saved screenshot.png ({image.width} × {image.height})")

The returned value is a Pillow image object. You can instead capture first and save it afterward:

import pyautogui

image = pyautogui.screenshot()
image.save("screenshot.png")

Passing the filename directly is convenient for a capture-and-save operation. Use the separate .save() step when you need to inspect or transform the image before writing it. Use an extension that matches the image format you want, such as .png.

Capture a rectangular region

Pass region as four integers in this order: (left, top, width, height). The final two values are width and height—not the right and bottom coordinates.

import pyautogui

# Capture a 300 × 400 rectangle starting at the screen's top-left corner.
region_image = pyautogui.screenshot(region=(0, 0, 300, 400))
region_image.save("region.png")

Change the first two values to move the rectangle from the screen’s top-left origin, and the last two to set its dimensions. This is a rectangular screen capture, not a request to target a particular application window; the documented screenshot call describes full-screen and region capture.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Pyle Wireless Switch Controller - High Performance Wireless Bluetooth Remote Joystick Game Controller for Switch Console - Turbo, Screenshot, Dual Vibration, RGB LED Light, 6-Axis Sensor, NFC
  • DUAL-MODE CONNECTIVITY: Supports BT wireless & USB cable wired connectivity with Bluetooth maximum receiving open distance of 10 meters. Equipped with a built-in lithium battery, 3.7v600ma that can last up to 8 hours
  • DUAL MOTOR VIBRATION: The switch game console controller has RGB LED lights & supports dual-point capacitive sensing touchpad and double motor vibration function so you can enjoy various games with a more authentic gaming experience
  • FOR SWITCH CONSOLE: This gaming controller is compatible with Switch console. Professional cooperation with Switch game processing chip, stable and reliable performance. Comes with USB cable for easy connection and operation
  • UPGRADED VERSION: Features a built-in three-axis gyroscope and three-axis accelerator and reacts to slightest pressure for improved accuracy. It also features turbo speed adjustment with 3 gears speed
  • ERGONOMIC DESIGN: This handheld remote joystick has a professional ergonomic design with optimized gamepad button layout and surface diversification color matching treatment to facilitate comfort even during long hours of game play

What the capture covers, and how fast it is

PyAutoGUI’s quickstart describes support for Windows, macOS, and Linux. Its FAQ says it currently handles only the primary monitor. If your workflow depends on another display, verify the behavior in your own environment before relying on the result.

The screenshot reference gives roughly 100 milliseconds as an example for a 1920 × 1080 capture. Treat that as an approximate documentation figure, not a performance guarantee: actual time can differ with hardware, operating system, display size, and environment.

Troubleshooting common problems

ImportError or “No module named pyautogui”

The package may have been installed into a different Python environment from the one running the script. Install it with the command for your platform using that environment’s Python, then run the script there.

Screenshot capture fails because a dependency is missing

Confirm that Pillow is installed. On Linux, check the platform packages named in PyAutoGUI’s installation documentation, including scrot, python3-tk, and python3-dev. On macOS, the screenshot documentation identifies the built-in screencapture command. If your distribution or environment differs, consult its current package instructions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Insta360 Link 2C - 4K Webcam for PC/Mac, Streaming Computer Camera with Auto Framing, 1/2" Sensor, HDR, AI Noise-Canceling Mic, Gesture Control, Webcam for Desktop Video Calls, Zoom, Teams, Twitch
  • Premium Image Quality: Capture every detail with an impressive 1/2" sensor, balanced, true-to-life 4K visuals with HDR and exceptional low light performance for quality videos in any light.
  • Professional Audio: Experience best-in-class audio with advanced AI noise-canceling algorithms. Filter out unwanted background noise for clear communication, even in busy environments.
  • True Focus: Keep your audience engaged with faster, more accurate Phase Detection Auto Focus (PDAF). No more blurry shots, just fast focusing and crisp video.
  • Natural Bokeh: Get a professional look by replicating a DSLR-like depth of field. Provides a realistic and natural bokeh effect, straight from Link Controller.
  • Auto Framing: Insta360 Link 2C automatically zooms and adjusts to keep everyone clearly in sight, whether it's one person or a group.

The saved rectangle is not the area you expected

Check that the tuple is (left, top, width, height). A common mistake is to supply right and bottom coordinates as the last two values.

The script does not capture another monitor or just one window

The FAQ describes PyAutoGUI as handling only the primary monitor, and the documented region argument selects a rectangle rather than an application window. Verify your exact display setup before building a workflow around it; do not assume this call targets a particular window.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

PyAutoGUI captures your computer’s screen. If what you need is an image of a web page rather than your local desktop, ScreenshotNeo captures a URL through a website screenshot API:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before the shot; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sign up for ScreenshotNeo’s free plan.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.