7
7
8
8
One screenshot per monitor::
9
9
10
- for filename in screenshotter .save():
10
+ for filename in sct .save():
11
11
print(filename)
12
12
13
13
14
14
Screenshot of the monitor 1::
15
15
16
- next(screenshotter.save(mon=1))
16
+ for filename in sct.save(mon=1):
17
+ print(filename)
17
18
18
19
19
20
A screenshot to grab them all::
20
21
21
- next(screenshotter.save(mon=-1, output='fullscreen.png'))
22
+ for filename in sct.save(mon=-1, output='fullscreen.png')):
23
+ print(filename)
22
24
23
25
24
26
Callback
@@ -39,7 +41,9 @@ Screenshot of the monitor 1 with callback::
39
41
rename(fname, newfile)
40
42
return True
41
43
42
- next(screenshotter.save(mon=1, callback=on_exists))
44
+
45
+ for filename in sct.save(mon=1, callback=on_exists):
46
+ print(filename)
43
47
44
48
45
49
Into the Python's console
@@ -48,7 +52,7 @@ Into the Python's console
48
52
::
49
53
50
54
>>> from mss import mss
51
- >>> sct = mss(display=':0' )
55
+ >>> sct = mss()
52
56
53
57
# Retrieve monitors informations
54
58
>>> displays = sct.enum_display_monitors()
@@ -76,8 +80,7 @@ Into the Python's console
76
80
StopIteration
77
81
78
82
# 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')
81
84
82
85
83
86
GNU/Linux
@@ -92,8 +95,8 @@ On GNU/Linux, you can specify which display to use (useful for distant screensho
92
95
print('Screenshot of display "{0}"'.format(display))
93
96
output = 'monitor{0}-%d.png'.format(display)
94
97
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):
97
100
print(filename)
98
101
99
102
@@ -107,21 +110,19 @@ This is an example using `frombytes() <http://pillow.readthedocs.io/en/latest/re
107
110
from PIL import Image
108
111
109
112
110
- with mss() as screenshotter :
113
+ with mss() as sct :
111
114
# We retrieve monitors informations:
112
- monitors = screenshotter .enum_display_monitors()
115
+ monitors = sct .enum_display_monitors()
113
116
114
117
# Get rid of the first, as it represents the "All in One" monitor:
115
118
for num, monitor in enumerate(monitors[1:], 1):
116
119
# Get raw pixels from the screen.
117
120
# This method will store screen size into `width` and `height`
118
121
# and raw pixels into `image`.
119
- screenshotter .get_pixels(monitor)
122
+ sct .get_pixels(monitor)
120
123
121
124
# 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)
125
126
126
127
# And save it!
127
128
img.save('monitor-{0}.jpg'.format(num))
0 commit comments