M
M
Meezmo2021-08-29 21:40:38
Screenshots
Meezmo, 2021-08-29 21:40:38

How to take a screenshot of a game in python?

I'm making a telegram bot that sends a screenshot of the screen. I use the mss library. It screenshots the desktop normally, but when the game is running (cs 1.6), it just sends a black screen. Is it possible to take a screenshot of a game in python?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alexbprofit, 2021-08-29
@alexbprofit

pyautogui

A
Artem Imaev, 2021-09-01
@AIRC24

it's simple but i don't know how it will work for you

import pyautogui
image = pyautogui.screenshot("screen.png", region=(0, 0, 300, 400))

if that: region=(the beginning of the photo frame in x, the beginning of the photo frame in y, the end of the photo frame in x, the end of the photo frame in y) the photo will be stored next to the file and the name is "screen.png"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question