+3 votes

Greetings,

Apparently the Printscreen doesn't send screencaptures to Windows clipboard (BTW, why?)... So, how can I take screenshots of my whole screen and save it as a file?

Thanks in advance.

in Engine by (105 points)

... and what does this have to do with Godot exactly? Have you tried Google searching first?

2 Answers

+8 votes
Best answer

In Godot 3.0, you would do-

var image = get_viewport().get_texture().get_data()
image.flip_y()
image.save_png("path/to/save/screenshot.png")
by (3,875 points)
selected by
+1 vote
by (164 points)

Those answers are for Godot 2.0.

In Godot 3.0, you would do-

var image = get_viewport().get_texture().get_data()
image.save_png("path/to/save/screenshot.png")

Thanks! It worked, but the screenshot is vertically flipped! :D

if Input.is_key_pressed(KEY_PRINT):
    # start screen capture
    var image = get_viewport().get_texture().get_data()
    image.save_png("c:/lixo/screenshot.png")

enter image description here

Add this line just before the save_as() function.

image.flip_y()
if Input.is_key_pressed(KEY_PRINT):
    # start screen capture
    var image = get_viewport().get_texture().get_data()
    image.flip_y()
    image.save_png("c:/lixo/screenshot.png")

Believe it or not, now it stopped saving screenshots. When I press PrintScreen, the program stutters a little like before, which seems it's saving the screenshot, but when I look inside it, there's no screenshot. :(

And before someone asks, yes, I have the permission for the folder and there's no file in there that cannot be overwritten.

Strange because it worked for me.

Even stranger: it worked for me. After sometime it stopped working. I'll check it out.

Thanks anyway!

P.S.: Found the problem. Apparently it did not work with Print Screen, but when I used another key it worked fine. Thanks again!

Okay. Posted it as answer. Why don'tcha select my answer instead?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.