Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
The shortest way to take a full-screen screenshot in Python is pyautogui.screenshot('screen.png'). It captures the primary monitor and writes a PNG through Pillow. For a multi-monitor desktop, use Pillow’s ImageGrab.grab(all_screens=True) or MSS, whose monitor index 0 represents the combined virtual desktop.
Choose the right capture method first
Your monitor layout and operating system determine the best library. PyAutoGUI is the simplest beginner recipe, Pillow is convenient when the rest of your program already uses PIL images, and MSS gives explicit control over individual monitors or the complete virtual desktop.
| Library | Best for | Image returned | Monitor coverage | Important prerequisite or caveat |
|---|---|---|---|---|
| PyAutoGUI | A one-line primary-monitor screenshot | A Pillow Image object | Primary monitor only | Uses Pillow; Linux documentation requires the scrot utility |
Pillow ImageGrab |
Programs that already process PIL images | A Pillow Image object | Entire screen by default; use all_screens=True for all displays |
Retina scaling on macOS and fallback utilities on Linux can affect setup |
| MSS | Enumerating monitors or capturing a virtual desktop | An MSS raw image, convertible with to_pil() |
monitors[0] is all monitors; higher indexes are individual monitors |
Save raw data with MSS tools or convert it before using Pillow APIs |
Install Python and the screenshot libraries
PyAutoGUI
Install PyAutoGUI with pip:
python -m pip install pyautogui
PyAutoGUI’s screenshot support uses Pillow. On Linux, install the scrot command through your distribution’s package manager if a capture fails because the utility is missing. Keep the desktop session unlocked and visible: these libraries capture the graphical display rather than a headless browser page.
Pillow
python -m pip install pillow
MSS
python -m pip install mss
Use a virtual environment for repeatable projects:
python -m venv .venv
# Windows
.venvScriptsactivate
# macOS or Linux
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install pyautogui pillow mss
Take a full-screen screenshot with PyAutoGUI
For the primary display, this is the complete program:
#1 Best Overall
- USB-C 2-in-1 storage OTG: The Lexar JumpDrive Dual Drive D40E features USB Type-A and Type-C connectors in a slim, portable form factor for easy device compatibility
- Transfer speeds up to 100MB/s: Based on internal testing, performance may vary depending upon the host device, interface, and usage conditions. 1MB=1,000,000 bytes
- Plug and Play: Widely compatible with USB Type-C smartphones, tablets, laptops, Macs, and traditional Type-A devices, no software installation required. The 360° swivel design allows for easy switching between connectors without the hassle of losing a cap
- Durable & Compact: The Lexar D40E USB memory stick features a metal enclosure, withstands temperatures from 0° to 50° C (32°F to 122°F), and is lightweight at 26g with dimensions of 70.4 x 16.9 x 11.7mm
- Security & Warranty: Securely protects files using an advanced security software solution with 256-bit AES encryption. Backed by a Lexar 3-year limited warranty
import pyautogui
pyautogui.screenshot('screen.png')
print('Saved screen.png')
screenshot() returns an image object and accepts a filename, so you can either save immediately or continue processing the returned Pillow image:
import pyautogui
image = pyautogui.screenshot()
print(image.size) # (width, height)
image.save('screen.png')
The filename extension selects the usual image format. Use an explicit path when a service or scheduled job must put files in a known directory:
from pathlib import Path
import pyautogui
output = Path('captures')
output.mkdir(exist_ok=True)
image = pyautogui.screenshot()
image.save(output / 'desktop.png')
PyAutoGUI currently handles only the primary monitor. If your workstation has two or more displays, do not assume this call includes the others; choose Pillow with all_screens=True or MSS instead.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsCapture the entire screen with Pillow
Pillow’s ImageGrab.grab() copies the whole screen when you omit bbox. The result is already a Pillow image, which makes cropping, resizing and format conversion straightforward:
from PIL import ImageGrab
image = ImageGrab.grab()
image.save('screen.png')
print(f'Saved {image.width} x {image.height} pixels')
Capture every display
Pass all_screens=True when the workflow needs all displays:
Rank #2
- High-speed USB 3.0 performance of up to 150MB/s(1) [(1) Write to drive up to 15x faster than standard USB 2.0 drives (4MB/s); varies by drive capacity. Up to 150MB/s read speed. USB 3.0 port required. Based on internal testing; performance may be lower depending on host device, usage conditions, and other factors; 1MB=1,000,000 bytes]
- Transfer a full-length movie in less than 30 seconds(2) [(2) Based on 1.2GB MPEG-4 video transfer with USB 3.0 host device. Results may vary based on host device, file attributes and other factors]
- Transfer to drive up to 15 times faster than standard USB 2.0 drives(1)
- Sleek, durable metal casing
- Easy-to-use password protection for your private files(3) [(3)Password protection uses 128-bit AES encryption and is supported by Windows 7, Windows 8, Windows 10, and Mac OS X v10.9 plus; Software download required for Mac, visit the SanDisk SecureAccess support page]
from PIL import ImageGrab
image = ImageGrab.grab(all_screens=True)
image.save('all-monitors.png')
print(image.size)
The captured image represents the desktop arrangement, including the coordinates occupied by each display. Mixed operating-system display scaling can change the pixel dimensions you see. On macOS, account for Retina scaling when comparing logical window dimensions with screenshot pixels. On Linux, Pillow documents fallback utilities such as gnome-screenshot, grim or spectacle when its preferred capture path is unavailable.
Limit the capture to a rectangle
A bounding box is useful when “full screen” means a known region rather than the whole desktop:
from PIL import ImageGrab
left, top, right, bottom = 0, 0, 1920, 1080
image = ImageGrab.grab(bbox=(left, top, right, bottom))
image.save('region.png')
Use coordinates measured in the same coordinate system as your operating system’s display APIs. For a true full desktop, omit bbox and let Pillow determine the screen bounds.
Capture one monitor or all monitors with MSS
MSS exposes a monitors collection. Index 0 is the full virtual desktop; indexes 1 and above identify individual monitors. This makes MSS the clearest option when your program must choose a display deliberately.
Save the combined virtual desktop
import mss
with mss.mss() as sct:
image = sct.grab(sct.monitors[0])
mss.tools.to_png(image.rgb, image.size, output='all-monitors.png')
The example writes the raw MSS capture to a PNG. If your installed version does not expose the tools namespace automatically, import it explicitly:
Rank #3
- What You Get - 2 pack 64GB genuine USB 2.0 flash drives, 12-month warranty and lifetime friendly customer service
- Great for All Ages and Purposes – the thumb drives are suitable for storing digital data for school, business or daily usage. Apply to data storage of music, photos, movies and other files
- Easy to Use - Plug and play USB memory stick, no need to install any software. Support Windows 7 / 8 / 10 / Vista / XP / Unix / 2000 / ME / NT Linux and Mac OS, compatible with USB 2.0 and 1.1 ports
- Convenient Design - 360°metal swivel cap with matt surface and ring designed zip drive can protect USB connector, avoid to leave your fingerprint and easily attach to your key chain to avoid from losing and for easy carrying
- Brand Yourself - Brand the flash drive with your company's name and provide company's overview, policies, etc. to the newly joined employees or your customers
import mss
import mss.tools
with mss.mss() as sct:
image = sct.grab(sct.monitors[0])
mss.tools.to_png(image.rgb, image.size, output='all-monitors.png')
List monitors and capture one by index
import mss
import mss.tools
with mss.mss() as sct:
for index, monitor in enumerate(sct.monitors):
print(index, monitor)
monitor_number = 1
image = sct.grab(sct.monitors[monitor_number])
mss.tools.to_png(image.rgb, image.size, output='monitor-1.png')
Because index 0 is reserved for the combined desktop, the first physical monitor normally starts at index 1. Enumerate the collection instead of hard-coding an index when users can rearrange displays.
Convert an MSS capture to Pillow
import mss
with mss.mss() as sct:
raw = sct.grab(sct.monitors[0])
image = raw.to_pil()
image.save('desktop-with-pillow.png')
Save, inspect and process the image
A screenshot is most useful when the program verifies what it wrote. Check the dimensions, file existence and (when appropriate) the color mode before passing the image to another step:
from pathlib import Path
from PIL import ImageGrab
path = Path('screen.png')
image = ImageGrab.grab()
image.save(path)
if not path.exists() or path.stat().st_size == 0:
raise RuntimeError('Screenshot was not written')
print({'path': str(path), 'size': image.size, 'mode': image.mode,
'bytes': path.stat().st_size})
Use PNG when you need a lossless, pixel-for-pixel capture suitable for text or later editing. Keep the file in a protected directory if the desktop may contain passwords, private messages or other sensitive information. A screenshot records whatever is visible, including notifications that appear during capture.
Which Python library should you use?
Choose PyAutoGUI when simplicity matters
Use pyautogui.screenshot('screen.png') for a script that only needs the primary display and should be easy for a beginner to read. It is also convenient when the rest of the automation already uses PyAutoGUI.
Choose Pillow when your pipeline is image-focused
ImageGrab.grab() returns a PIL image immediately. That avoids conversion when you need to crop, annotate or pass the capture to existing Pillow code. Add all_screens=True for a multi-display desktop.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #4
- GOOD VALUE PACKAGE - 1 Pack 32GB Memory Stick USB 2.0 Flash Drives with great cost performance and high quality.
- BIG CAPACITY - The available capacity: 29.10GB-29.8GB, You can save the data of movies, music, photos, designs, programs, manuals, handouts in a high speed.Good performance in digital data storing, transferring and sharing with families, friends, workmates, clients and machines.
- EASY TO USE & PLUG AND WORK - Support windows 7 / 8 / 10 / Vista / XP / 2000 / ME / NT Linux and Mac OS, Compatible with USB2.0 and below.
- TWISTTURN DESIGN & EASY CARRY - The metal clip rotates 360° round the ABS plastic body which with rubber oil skin feeling finish. The capless design can avoid lossing of cap, and providing efficient protection to the USB port.
- WARRANTY & SUPPORT - SIMMAX logo is laser printed on the USB connector surface, our products are of good quality and we promise that any problem about the product within one year since you buy.
Choose MSS when monitor geometry is a requirement
MSS exposes monitor definitions directly and distinguishes the virtual desktop from each physical display. It is the most explicit choice for recording a selected monitor, handling several displays, or inspecting monitor rectangles before capture.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshooting common failures
“No screenshot was saved” or a missing command on Linux
- Confirm the package is installed in the same Python environment that runs the script:
python -m pip show pyautogui pillow mss. - For PyAutoGUI on Linux, install the documented
scrotutility, then rerun the script. - For Pillow, try the platform fallback utility documented for your desktop, such as
gnome-screenshot,grimorspectacle.
The image contains only one display
That is expected from PyAutoGUI’s current primary-monitor limitation. Replace it with ImageGrab.grab(all_screens=True) or MSS index 0.
The dimensions look larger or smaller than expected on macOS
Retina displays use scaling, so logical UI coordinates and physical screenshot pixels can differ. Print image.size and use the returned dimensions when cropping or comparing images instead of assuming a window’s point size equals its pixel size.
A selected MSS monitor is wrong
Print every entry in sct.monitors and inspect the index-to-rectangle mapping at runtime. Do not assume the operating system’s display order remains constant after a monitor is unplugged or rearranged.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteThe capture is blank or shows an unexpected desktop
- Make sure the process has access to an active graphical session rather than a headless shell.
- Unlock the desktop and bring the intended content to the foreground before capture.
- Check whether a privacy or screen-recording permission on the operating system is blocking access, then grant permission to the Python runtime if required.
The file is enormous
Full virtual desktops and high-DPI displays contain many pixels. Capture only the required monitor or bounding box, or resize the PIL image after capture when the destination does not need native resolution.
Best Value
- 【16GB Flash Drive】USB flash drives with 16GB capacity, meet your needs of daily use on work, school, home and travelling for photos, music, videos, files storage and transfer. IMEASON thumb drives can be used to store different files, easy to data backup.
- 【Metal Swivel Cap Design】USB thumb drive is metal swivel cover provides extra protection for the usb thumbdrive connector, no usb drive cap to lose; keychain design makes it easier to carry without worrying lose it.
- 【Wide Compatibility】USB drive supports Windows 7/8/10/11 / Vista / XP / Unix / 2000 / ME / NT Linux and Mac OS, also Supports USB 2.0 and 1.1 ports. USB Stick support TV, desktop, notebook computer, car, audio and other device. The USB Memory Stick is your great data storage and transfer companion with traveling and working.
- 【Easy to use】usb memory stick is plug and play without any software installation. Just simply plug the Flashdrive into the port of your USB-compatible devices such as computer, laptop to start data storage or transmission.
- 【What You Get】16 GB USB Flash Drive Thumb Drive, The default format of the usb storage flash drive is FAT32.
Reliability and performance considerations
A single screenshot is normally a synchronous operation: the call returns after the image has been read from the display. For repeated captures, create one MSS context and reuse it rather than repeatedly opening and closing resources. Save to a fast local directory, then move or upload the finished file. If a capture is part of a scheduled job, log the selected monitor, dimensions, output path and file size so a failed or misrouted capture is diagnosable.
Do not treat a screenshot as an application-state guarantee. A window can repaint while the capture occurs, a notification can cover content, and a display can be asleep or disconnected. If consistency matters, wait for the application to reach a known state before calling the library, and validate the output dimensions afterward.
Or skip the browser setup
If what you actually need is a screenshot of a website rather than the desktop in front of you, ScreenshotNeo returns a clean image or PDF from one API request. It accepts the cookie or consent banner like a visitor, removes more than 60 known consent platforms plus newsletter popups and chat widgets, and lets you turn each step off. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed; response headers report the page verdict and billing result.
Free tools Windows power users keep installed
One-click scans. No signup required.
Install the Python HTTP client and call the endpoint (see the ScreenshotNeo documentation):
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
The equivalent cURL request is:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
And in Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
ScreenshotNeo also provides full-page captures with lazy images loaded, CSS-selector element shots, dark mode, device presets and custom viewports, retina scale, PDF paper and page-range controls, custom CSS and JavaScript, click and wait conditions, ad/tracker/request blocking, headers, cookies, user-agent, authorization, timezone and geolocation settings, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous jobs with signed webhooks, bulk capture for up to 100 URLs per call, a usage API and an OpenAPI specification. An MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.
The Free plan includes 1,000 screenshots each month with no card. Paid plans start at $5 for 3,000 shots; every feature is available on every plan, and annual billing provides two months free. Create a free ScreenshotNeo account to try it.
Minimal decision checklist
- Primary monitor only: use
pyautogui.screenshot('screen.png'). - All displays with a PIL workflow: use
ImageGrab.grab(all_screens=True). - Explicit monitor selection or virtual-desktop geometry: use MSS and inspect
sct.monitors. - Website capture without managing a local browser: use ScreenshotNeo’s API or MCP server.
Frequently Asked Questions
How can I confirm which monitor an MSS index refers to?
Print sct.monitors before capturing; entry 0 is the combined virtual desktop and each later entry contains one monitor’s rectangle.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →What should a script record for a dependable screenshot job?
Record the output path, selected monitor or bounding box, image dimensions and file size, then fail the job if the file is missing or empty.
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.

