Use Screenshot in code

Question:
How to take screenshot of a screen

Repl link:

``https://replit.com/@mobereolanedia/Import-homescreen?s=app
code snippet

Hi @mobereolanedia , welcome to the forums!
What OS are you using?

1 Like

Android or Samsung im on my phone

1 Like

@mobereolanedia In that case, try pressing the volume down button and the power button at the same time, which will take a screenshot.

How to take a screenshot with code

Since Repls don’t run on your device, but rather on Replit’s servers, I don’t believe this is possible.

2 Likes

Maybe they meant taking a screenshot of the Repl’s output?

If it weren’t for the OP’s other posts asking how to capture their home screen from a Repl, perhaps.

Oh, well, this explains everything. Thanks for pointing that out.

though, if you want to use python to screenshot your screen outside replit
(as @Firepup650 mentioned, a repl is a linux virtual machine, or basically a new computer differ from your deivce, you can’t let it screenshot your own device, like you can’t directly do anything to one room when you’re in another separated room)
you can use a python package called pyautogui. example code:

import pyautogui
image = pyautogui.screenshot()
image.save(r"path/to/save/location/image.png")

note that this is a community package in pypi, so you need pip to install it. And if you tried to run this code in replit, you’re going to see a screenshot of your output tab instead.