marvin_
Posts: 1
Joined: Sat Nov 16, 2019 5:22 pm

Screenshot help

Sat Nov 16, 2019 6:07 pm

Hi
In the codeclub session today one of the class wanted some way to save the pictures that are created in the Paint Box project. Her idea was a sprite that, when it is clicked, takes a screenshot. We are in a public library and so will not be able to download any third party apps. Any suggestions on achieving this?
Thanks

makerbob
Posts: 2
Joined: Thu May 30, 2019 11:34 am

Re: Screenshot help

Mon Nov 18, 2019 10:45 am

Hi Marvin,

Sorry but I don't think this is possible using vanilla Scratch.

My only suggestion would be to use the built in screenshot feature of the operating system and save that image somewhere.

You may be familiar with this feature already but this page seems to have some nice instructions: https://www.take-a-screenshot.org/windows.html

Bob

RossDv8
Posts: 243
Joined: Thu Jan 21, 2016 12:35 pm

Re: Screenshot help

Mon Dec 02, 2019 6:17 am

This post is getting old, and nobody has answered it, and I am guessing what is needed.
I haven't been able to find any information about scratch. I know it is on my Pi by default, but I have no idea what it can do, and despite googling "raspbian can scratch execute a bash script" there were no answers.
However, before I realised there were some actual GUI screenshot prograns in the repository, I played with scripting capture.

It looks to me as if scratch can be used to write games. And it sounds as if you want to click a sprite in a game to take a screen shot, because as an old Commodore 64 user games are what I mostly associate sprites with.
In which case I would think one could create sprites that can do stuff when clicked.

So, can scratch execute an action when you click a sprite? Could that action be to run a bash script?

If so, and 'If' your Pi has two programs installed. (I'm pretty sure mine had both) you might be lucky.
scrot
zenity

If you enter each of these in a terminal and press enter and get anything other than 'command not found' you probably have them.

If you do, you might try writing a bash script like this one:

Code: Select all

#!/bin/bash
# change -d [number] to therequired delay in seconds
# MAKE SURE you have created a Screenshots  directory in /Pictures  :-)
scrot -d 8 ~/Pictures/Screenshots/%b%d::%H%M%S.png
zenity --info --text="Screenshot Saved to /Pictures/Screenshots"
end
And telling your project to run it when you click the sprite.
As a test, if you run the following in a terminal, and you have zenity, you should get a message box pop up on screen:

Code: Select all

zenity --info --text="Screenshot Saved to /Pictures/Screenshots"
And if you run the next one in a terminal and you have scrot, you can check in /Pictures/Screenshots and see if it is there.

Code: Select all

scrot -d 8 ~/Pictures/Screenshots/%b%d::%H%M%S.png
Note:
Obviously you need to make the bash script executable. Using Raspbian, you could just put it in the Desktop folder and click it from there to take a screen shot.
You could I suppose make a hotkey to run it.
I run it from an icon on the panel using the script below, which would have to be edited for locations of course:

Code: Select all

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
StartupNotify=true
Name=SCREENSHOT
Comment=Take screenshot
Exec=/home/pi/BASH-scripts/screenshot
Categories=Application;
Icon=/home/pi/Custom-Icons/camera-icon.png
Name[en_AU]=SCREENSHOT
Other than that, the Prnt Scr function on the Keyboard works nicely on the Pi. But I answered because the post asked about taking a screenshot by clicking on something :-)
Remember, nobody is listening to you
until you fart ...

User avatar
rpdom
Posts: 15610
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Screenshot help

Mon Dec 02, 2019 10:05 am

RossDv8 wrote:
Mon Dec 02, 2019 6:17 am
So, can scratch execute an action when you click a sprite?
Yes. It would be pointless if it couldn't.
Could that action be to run a bash script?
Not to my knowledge. Scratch is a pretty self-contained environment. It can have extensions to perform other functions like accessing GPIO, but I'm pretty certain it doesn't have anything that can run an arbitrary command.

RossDv8
Posts: 243
Joined: Thu Jan 21, 2016 12:35 pm

Re: Screenshot help

Mon Dec 02, 2019 11:50 pm

Not to my knowledge. Scratch is a pretty self-contained environment. It can have extensions to perform other functions like accessing GPIO, but I'm pretty certain it doesn't have anything that can run an arbitrary command.
Thanks, I couldn't find anything on Google or ChookChook that even hinted at what scratch might be able to do,,
Remember, nobody is listening to you
until you fart ...

Return to “Scratch”