MSS (Multiple Screenshots)

10.1.0 · active · verified Fri Apr 10

MSS is an ultra-fast, cross-platform Python module for taking screenshots, built purely in Python using ctypes. It supports Windows, macOS, and Linux, and is optimized for speed, offering multi-monitor and thread-safe capabilities. The library is actively maintained with frequent releases, currently at version 10.1.0, and often integrates with other image processing libraries like Pillow, NumPy, and OpenCV for advanced manipulation.

Warnings

Install

Imports

Quickstart

This quickstart captures a screenshot of the primary monitor (typically `sct.monitors[1]`, as `sct.monitors[0]` often represents all monitors combined) and saves it as a PNG file using `mss.tools.to_png`.

from mss import MSS
import mss.tools

# Take a screenshot of the primary monitor
with MSS() as sct:
    # Get information of monitor 1
    monitor_info = sct.monitors[1]
    
    # Grab the data
    sct_img = sct.grab(monitor_info)
    
    # Save to the picture file
    mss.tools.to_png(sct_img.rgb, sct_img.size, output="screenshot.png")
    print("Screenshot saved to screenshot.png")

view raw JSON →