0

I want to send a screenshot over a discord webhook. I am using the dhooks module for this. To send a file, I need a "file-like object" so I want to get a file-like object without having the need to store the screenshot as a file. Any idea how to do this?

1 Answers1

2

I just added an example in the documentation:

import mss
import mss.tools


with mss.mss() as sct:
    # The monitor or screen part to capture
    monitor = sct.monitors[1]  # or a region

    # Grab the data
    sct_img = sct.grab(monitor)

    # Generate the PNG
    png = mss.tools.to_png(sct_img.rgb, sct_img.size)
Tiger-222
  • 6,677
  • 3
  • 47
  • 60