WARNING: this project is under heavy development, do not use in prod.
An attempt to create a full functionnal cross-platform multi-screen shot module in pure python using ctypes.
Very basic, it will grab one screen shot by monitor or a screen shot of all monitors and save it to an optimised/progressive PNG/JPEG file.
MSS is for Multi-Screen Shot.
Python. And that is all :) MSS is writen in pure python, it uses ctypes. ctypes has been introduced in Python 2.5, before it will need ctypes modules to be installed separately.
You can see the support table. Feel free to try MSS on a system we had not tested, and let report us by creating an issue.
If you just want to try MSS on your system:
$ python mss.py
If you want to use MSS on your project, just call a new instance of MSS*() and then save().
You can pass oneshot=True to create one screen shot of all monitors.
# You can determine automatically which class to use:
from platform import system
from mss import *
systems = {
'Linux' : MSSLinux,
'Windows': MSSWindows,
'Darwin' : MSSMac
}
try:
MSS = systems[system()]
except KeyError:
err = 'System "{0}" not implemented.'.format(system())
raise NotImplementedError(err)
# Or simply import the good class:
# from mss import MSSLinux as MSS
try:
mss = MSS(debug=False)
# One screen shot per monitor
for filename in mss.save():
print('File "{0}" created.'.format(filename))
# A shot to grab them all :)
for filename in mss.save(oneshot=True):
print('File "{0}" created.'.format(filename))
except Exception as ex:
print(ex)
raise
Just for fun ... Show us your screen shot with all monitors in one file, we will update the gallery ;)
If you access a computer using SSH, do not forget to enable X11 forwarding, option -X. Else you will end on a segfault.