Use pyautogui.screenshot() to capture the primary display. Pass a filename to save the image immediately, or pass region=(left, top, width, height) to capture a rectangle. The call returns a Pillow image object either way.
Install PyAutoGUI
Install PyAutoGUI into the same Python environment that will run your script. The official installation guide gives these commands:
- macOS or Linux:
python3 -m pip install pyautogui - Windows:
py -m pip install pyautogui
On Linux, PyAutoGUI’s installation documentation also identifies scrot, python3-tk, and python3-dev as packages to install. Its screenshot documentation says Pillow is required, calls out the built-in screencapture command on macOS, and calls out scrot on Linux. Package availability can vary by platform and environment, so consult the current documentation if a dependency is missing: PyAutoGUI installation guide and screenshot reference.
Capture and save the full screen
This runnable example saves a PNG in the current working directory and keeps the returned image available for further processing:
Recommended Free Tools
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
import pyautogui
image = pyautogui.screenshot("screenshot.png")
print(image.size)
The filename argument saves the screenshot and screenshot() returns a Pillow image object. You can also capture first and save later:
import pyautogui
image = pyautogui.screenshot()
image.save("screenshot.png")
Use the second form when you want to inspect or transform the image before choosing where or how to save it. The project README shows both filename-based capture and saving the returned image with .save(): PyAutoGUI project README.
Capture only a rectangular region
Pass four integers as (left, top, width, height). The third and fourth values are dimensions, not the right and bottom coordinates.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
import pyautogui
region_image = pyautogui.screenshot(region=(0, 0, 300, 400))
region_image.save("region.png")
This captures a 300-by-400-pixel rectangle starting at the display coordinate (0, 0). Change the left and top values to move the rectangle and the width and height values to resize it. The documented API describes full-screen and rectangular-region captures; it does not establish a window-targeted capture call.
Choose the right save and capture pattern
| Need | Use | What it does |
|---|---|---|
| Save a full-screen capture immediately | pyautogui.screenshot("screenshot.png") |
Saves to the filename and returns the image object. |
| Process the image before saving | image = pyautogui.screenshot(), then image.save(...) |
Keeps the Pillow image available for later work. |
| Capture a rectangle | pyautogui.screenshot(region=(left, top, width, height)) |
Limits capture to the specified rectangle. |
Use a filename extension that matches the image format you intend to save; the official examples use PNG filenames.
Platform and display limits
PyAutoGUI’s quickstart describes support for Windows, macOS, and Linux. Its FAQ says it currently handles only the primary monitor. If your script depends on a secondary display, verify the behavior in your specific operating system and setup before relying on it: quickstart and FAQ.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Performance expectations
The screenshot reference gives roughly 100 milliseconds as an example for a 1920×1080 capture. That is an approximate documentation figure, not a performance guarantee or a benchmark across machines. Actual timing can differ with display size, operating system, dependencies, and system load. If capture speed matters in your application, measure it on the machines and display configurations where the script will run.
Troubleshoot common screenshot problems
ImportError or missing Pillow
Install PyAutoGUI and its screenshot dependency in the Python environment used to run the script. If multiple Python versions or virtual environments are installed, invoke pip through the same interpreter that starts the program, such as python3 -m pip or py -m pip.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsLinux capture command or package is missing
PyAutoGUI’s documentation identifies scrot for Linux screenshot support and lists python3-tk and python3-dev in its installation guidance. Check those dependencies in the Linux environment where the script runs, including containers or remote sessions, and consult the current installation guide for platform-specific steps.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
The region is misplaced or the result has the wrong size
Check the tuple order: (left, top, width, height). A tuple such as (0, 0, 300, 400) means a 300-pixel width and 400-pixel height from the upper-left coordinate, not a rectangle ending at (300, 400).
The screenshot does not include another monitor
The PyAutoGUI FAQ describes capture of the primary monitor only. Confirm which display is primary in the operating system and test the needed configuration; do not assume this API captures every connected display.
The screenshot is slower than expected
The roughly 100 ms figure applies only as an illustrative documented timing for a 1920×1080 screenshot. Time the operation in your actual environment rather than using that number as a service-level expectation.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Or skip the browser setup
PyAutoGUI captures a local desktop. If what you need is a screenshot of a web page by URL, ScreenshotNeo provides a one-request screenshot API and MCP server for developers. Its API can return PNG, JPEG, WebP, or PDF. See the ScreenshotNeo API documentation.
curl -G "https://api.screenshotneo.com/v1/shot"
-d access_key=YOUR_API_KEY
--data-urlencode url=https://stripe.com
-o shot.webp
- It accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off.
- Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing; the response includes
X-Page-VerdictandX-Billedheaders. - Its MCP server offers
take_screenshot,get_page_info, andcapture_pdftools for AI agents and MCP clients. - The Free plan includes 1,000 shots per month with no card required; paid plans start at $5 for 3,000 shots. Every feature is available on every plan.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Frequently Asked Questions
Does PyAutoGUI return an image object after saving a screenshot?
Yes. pyautogui.screenshot("screenshot.png") saves the image and returns a Pillow image object.
Can PyAutoGUI capture a specific application window?
The documented screenshot API described here supports the full screen or a rectangular region; it does not establish a window-targeted capture method.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Quick Recap
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.

