If you’re looking to take screenshots of websites, you are in the wrong place—check our my website screenshots guide instead. This guide is about capturing your desktop: applications, games, or anything displayed on your screen.
Quick Comparison
| Library | Speed | Cross-platform | Best For |
|---|---|---|---|
| Python MSS | Fast (30-60 FPS) | Yes | General purpose |
| DXcam | Very fast (240+ FPS) | Windows only | Gaming/streaming |
| PyAutoGUI | Slow (1-5 FPS) | Yes | Automation scripts |
Python MSS: The best general-purpose choice
Python MSS is my recommendation for most use cases—it’s fast, cross-platform, and reliable.
import mss
with mss.mss() as sct: # Capture the entire screen screenshot = sct.grab(sct.monitors[0])
# Save to file mss.tools.to_png(screenshot.rgb, screenshot.size, output='screenshot.png')Best for: General desktop capture on any platform.
DXcam: Maximum Performance, Windows only
For gaming, streaming, or any high-FPS application, dxcam is unbeatable on Windows.
import dxcam
camera = dxcam.create()frame = camera.grab() # Returns numpy array
# Or continuous capturecamera.start(target_fps=60)# ... frames available via camera.get_latest_frame()camera.stop()Best for: Game capture, screen recording, real-time processing.
PyAutoGUI: Automation first, capture second
PyAutoGUI is the easiest to use, though slower. Great for automation scripts.
import pyautogui
# Full screenscreenshot = pyautogui.screenshot()screenshot.save('screenshot.png')
# Specific regionregion_shot = pyautogui.screenshot(region=(0, 0, 500, 500))Best for: Automation scripts, simple captures, beginners.
Capturing Specific Monitors
With mss
import mss
with mss.mss() as sct: # List all monitors for i, monitor in enumerate(sct.monitors): print(f"Monitor {i}: {monitor}")
# Capture specific monitor (1 = first monitor) monitor_1 = sct.grab(sct.monitors[1])
# Capture all monitors combined all_monitors = sct.grab(sct.monitors[0])With dxcam
import dxcam
# List available outputsoutputs = dxcam.device_info()
# Create camera for specific monitorcamera = dxcam.create(output_idx=0) # First monitorCapturing Specific Regions
With mss
import mss
with mss.mss() as sct: region = { 'left': 100, 'top': 100, 'width': 500, 'height': 500 } screenshot = sct.grab(region)With DXcam
import dxcam
camera = dxcam.create()frame = camera.grab(region=(100, 100, 600, 600)) # left, top, right, bottomWith pyautogui
import pyautogui
# region = (left, top, width, height)screenshot = pyautogui.screenshot(region=(100, 100, 500, 500))Continuous Capture (Screen Recording)
With DXcam (Fastest)
import dxcamimport time
camera = dxcam.create(output_color="BGR")camera.start(target_fps=60)
frames = []start = time.time()
while time.time() - start < 5: # Record for 5 seconds frame = camera.get_latest_frame() if frame is not None: frames.append(frame)
camera.stop()print(f"Captured {len(frames)} frames")With Python MSS
import mssimport time
frames = []start = time.time()
with mss.mss() as sct: monitor = sct.monitors[1]
while time.time() - start < 5: frame = sct.grab(monitor) frames.append(frame)
print(f"Captured {len(frames)} frames")Converting to Other Formats
Python MSS to PIL Image
import mssfrom PIL import Image
with mss.mss() as sct: screenshot = sct.grab(sct.monitors[1]) img = Image.frombytes('RGB', screenshot.size, screenshot.bgra, 'raw', 'BGRX') img.save('screenshot.png')Python MSS to NumPy Array
import mssimport numpy as np
with mss.mss() as sct: screenshot = sct.grab(sct.monitors[1]) img_array = np.array(screenshot) # BGRA formatDXcam Output
DXcam returns NumPy arrays directly:
import dxcam
camera = dxcam.create(output_color="RGB") # or "BGR" for OpenCVframe = camera.grab() # Returns numpy arrayPerformance Benchmarks
Tested on Windows 10, 1920x1080 monitor:
| Library | FPS | Notes |
|---|---|---|
| dxcam | 240+ | DirectX-based |
| mss | 30-60 | Cross-platform |
| PIL ImageGrab | 10-15 | Built-in |
| pyautogui | 1-5 | Uses PIL internally |
Choosing the Right Library
Need high FPS (gaming/streaming)?├── Yes → Use dxcam (Windows only)└── No ├── Cross-platform needed? │ ├── Yes → Use mss │ └── No │ ├── Already using PIL? → Use ImageGrab │ └── Want automation? → Use pyautoguiWebsite Screenshots versus Desktop Screen Capture
As a reminder on what to use and when:
| Task | Use This |
|---|---|
| Screenshot a website | Playwright |
| Screenshot desktop apps | Python MSS or DXcam |
| Record gameplay | DXcam |
| Automate desktop tasks | PyAutoGUI |
If you need to capture websites, don’t use desktop capture libraries—they’ll just capture your browser window. Use proper website screenshot tools instead.
Summary
Desktop screen capture in Python:
- Python MSS: Best general-purpose choice (fast, cross-platform)
- DXcam: Best for gaming/high-FPS (Windows only)
- PyAutoGUI: Easiest to use (but slowest)
For website screenshots, just use Playwright for Python instead or check our guide on website screenshots in Python.
Frequently Asked Questions
If you read the article, but still have questions. Please, check the most frequently asked. And if you still have questions, feel free reach out at support@screenshotone.com.
What is the difference between desktop screen capture and website screenshots?
Desktop screen capture captures what's displayed on your monitor (any application). Website screenshots render a web page in a browser. Use Playwright/Selenium for websites, use Python MSS/DXcam for desktop capture.
What is the fastest Python screen capture library?
DXcam is fastest on Windows (240+ FPS), followed by Python MSS (30-60 FPS cross-platform). PyAutoGUI is slowest but easiest to use. Choose based on your speed requirements and platform.
How to capture a specific monitor in Python?
Use mss with the monitor parameter. mss.monitors[1] is the first monitor, mss.monitors[2] is the second, etc. mss.monitors[0] captures all monitors combined.