77
88One screenshot per monitor::
99
10- for filename in screenshotter .save():
10+ for filename in sct .save():
1111 print(filename)
1212
1313
1414Screenshot of the monitor 1::
1515
16- next(screenshotter.save(mon=1))
16+ for filename in sct.save(mon=1):
17+ print(filename)
1718
1819
1920A screenshot to grab them all::
2021
21- next(screenshotter.save(mon=-1, output='fullscreen.png'))
22+ for filename in sct.save(mon=-1, output='fullscreen.png')):
23+ print(filename)
2224
2325
2426Callback
@@ -39,7 +41,9 @@ Screenshot of the monitor 1 with callback::
3941 rename(fname, newfile)
4042 return True
4143
42- next(screenshotter.save(mon=1, callback=on_exists))
44+
45+ for filename in sct.save(mon=1, callback=on_exists):
46+ print(filename)
4347
4448
4549Into the Python's console
@@ -48,7 +52,7 @@ Into the Python's console
4852::
4953
5054 >>> from mss import mss
51- >>> sct = mss(display=':0' )
55+ >>> sct = mss()
5256
5357 # Retrieve monitors informations
5458 >>> displays = sct.enum_display_monitors()
@@ -76,8 +80,7 @@ Into the Python's console
7680 StopIteration
7781
7882 # Save pixels to a PNG file: option 2
79- >>> mon = displays[1]
80- >>> sct.to_png(data=pixels, width=mon['width'], height=mon['height'], output='monitor-1.png')
83+ >>> sct.to_png(data=pixels, output='monitor-1.png')
8184
8285
8386GNU/Linux
@@ -92,8 +95,8 @@ On GNU/Linux, you can specify which display to use (useful for distant screensho
9295 print('Screenshot of display "{0}"'.format(display))
9396 output = 'monitor{0}-%d.png'.format(display)
9497
95- with MSS(display=display) as screenshotter :
96- for filename in screenshotter .save(output=output):
98+ with MSS(display=display) as sct :
99+ for filename in sct .save(output=output):
97100 print(filename)
98101
99102
@@ -107,21 +110,19 @@ This is an example using `frombytes() <http://pillow.readthedocs.io/en/latest/re
107110 from PIL import Image
108111
109112
110- with mss() as screenshotter :
113+ with mss() as sct :
111114 # We retrieve monitors informations:
112- monitors = screenshotter .enum_display_monitors()
115+ monitors = sct .enum_display_monitors()
113116
114117 # Get rid of the first, as it represents the "All in One" monitor:
115118 for num, monitor in enumerate(monitors[1:], 1):
116119 # Get raw pixels from the screen.
117120 # This method will store screen size into `width` and `height`
118121 # and raw pixels into `image`.
119- screenshotter .get_pixels(monitor)
122+ sct .get_pixels(monitor)
120123
121124 # Create an Image:
122- img = Image.frombytes('RGB',
123- (screenshotter.width, screenshotter.height),
124- screenshotter.image)
125+ img = Image.frombytes('RGB', (sct.width, sct.height), sct.image)
125126
126127 # And save it!
127128 img.save('monitor-{0}.jpg'.format(num))
0 commit comments