Cross Platform Screen capture using Python MSS


mss is a cross-platform screenshots module for python that supports multiple monitor setups. The mss module also has a bundle command line version of mss for taking screenshots

Installing mss

# Install mss module globally
pip install mss

# Install mss in a virtualenv with pipenvn
mkdir mss-test
cd mss-test
pipenv install mss
pipenv shell

Use mss from the command line

$ mss
# Output
C:\Dev\playground\winscreencap\monitor-1.png

Call mss cli as a python modulee

$ python -m mss
# Output
C:\Dev\playground\winscreencap\monitor-1.png

Capture a Screenshot from python

from mss import mss

with mss() as sct:
    sct.shot()

References