1import mss
2import mss.tools
3
4
5with mss.mss() as sct:
6 # The screen part to capture
7 monitor = {"top": 160, "left": 160, "width": 160, "height": 135}
8 output = "sct-{top}x{left}_{width}x{height}.png".format(**monitor)
9
10 # Grab the data
11 sct_img = sct.grab(monitor)
12
13 # Save to the picture file
14 mss.tools.to_png(sct_img.rgb, sct_img.size, output=output)
15 print(output)