Search code examples
pythonpython-3.ximagepython-imaging-libraryscreenshot

Take a screen shot of a specif area and save as variable


I want to make a program taking a cropped screenshot (like Windows+Shift+s) and save it as variable, not as a file.

  1. How do I Programmatically open this win+shift+s window?

  2. How to directly get the output without saving this as a picture?

I'm using python


Solution

  • you will need to:

    1. trigger the Print screen key (any keyboard library should allow it)
    2. retrieve the data from the clipboard (you will maybe forced to save it as a temporary file and then read from it)
    3. then parse the data it will be it will png format.