Skip to content
Advertisement

How to take a screenshot from part of screen with mss python?

I have a simple code here:

JavaScript

result.png

enter image description here

But I want to take a part of screen like this:

enter image description here

Thanks for help!

Advertisement

Answer

As explained on https://python-mss.readthedocs.io/examples.html, something like this should work:

JavaScript

This is just the example given on the website. You can adjust the part of the screen that you are taking a screenshot of by modifying the monitor dictionary. As an example you could change it from {"top": 160, "left": 160, "width": 160, "height": 135} to {"top": 10, "left": 14, "width": 13, "height": 105}. You will have to modify it to capture the part of the screen that you want.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement