[SOLVED] Create and save Desktop Screenshot

Is there any way to automatically create a screenshot - not of the game but of the desktop of the pc and save it as an image file?

In my game there is at one point a fourth-wall-break when one of the characters is more or less "trying to break out" from the game. For that reason I need a screenshot of the pc desktop from this time as a jpg/png that is used in the background of the scene.

Is there any way to do that in the game, or is it only possible by running an external script?
Do you use windows?

Hold the windows button, then press PrtScrn (Print Screen)
to do what you want, requires a plugin to make this shot and saved as
parallax and call it to change the background of this parallax.

it might not work if you use tilesets as you wont see it, so what is more
behind this mechanic you want to achieve?
Well, basically my game features aside from the movement in the open world "cutscenes" that are not 100% fluently animated, but more like single frames but with full sound effects and voice acting so it feels like an anime scene.
I simply use for that the "Show Picture" command.

And in one of this scenes I want to give the impression as one of the characters is "trying to reach out" of the game. For that I need an image in the Background (via "Show Picture") that looks like the desktop of the player and place another image (that is already in the game files) above this.

So what I need is
1. That the game takes either a desktop screenshot every time the game starts and just replace the old one or just takes a desktop screenshot once when a command is run before the mentioned scene happens.
2. That it saves this screenshot automatically as an image file (jpg/png/bmp) that can be directly used with the "Show Picture" command.

I don't know if this is possible with a plugin or just a few lines of code that I can use in an event, but I hope so^^

EDIT: And yes, it shall be in a way that the player does not have to active press any button. In fact it shall be in a way that the player don't even recognize this and is a bit confused when this scene happens
That's not really a thing that's possible. You can take a screenshot of the current screen - though I don't think there exists a plugin for that, so you'd need to dedicate a fair amount of effort to coding this.
But as for taking a screenshot of something that's not currently being displayed on the screen, as far as I'm aware, that's not a thing you can do at all.
The closest thing might be grabbing the current wallpaper from %AppData%\Roaming\Microsoft\Windows\Themes and praying that it's in a format you can make use of.

Alternatively (though that really is a fair amount of effort) - make a transparent window, and within it a smaller window that looks like your game's window, so you'd be able to make some "breaking out" animation.
While taking a screenshot of the active window is something that could probably be easily done via a plugin, and taking a full capture of the full screen (assuming the game is in windowed mode) might also be possible, taking a screenshot of the windows desktop behind the game would be nearly impossible for a couple of reasons.

First, they aren't actively being drawn in video memory anywhere, if your game is fullscreen. Windows optimizes resource usage when a fullscreen game is open, and doesn't waste resources drawing anything that isn't in view. Second, even if they were in memory, RPG Maker has no way to dig through the players VRAM to find it. Third, even if you did somehow find a way to do that, most antivirus programs are going to stop that dead in its tracks because that's the sort of thing malware would do.

While it's not going to be quite as funny to the player, your best option is to make something that looks similar to a windows desktop, and pretend it's a computer, and not specifically the players.
That's not really a thing that's possible. You can take a screenshot of the current screen - though I don't think there exists a plugin for that, so you'd need to dedicate a fair amount of effort to coding this.
But as for taking a screenshot of something that's not currently being displayed on the screen, as far as I'm aware, that's not a thing you can do at all.
The closest thing might be grabbing the current wallpaper from %AppData%\Roaming\Microsoft\Windows\Themes and praying that it's in a format you can make use of.

Alternatively (though that really is a fair amount of effort) - make a transparent window, and within it a smaller window that looks like your game's window, so you'd be able to make some "breaking out" animation.
It's probably not entirely impossible. You should be able to grab an image of the current wallpaper, a list of each item on the desktop, the position of each item on the desktop, and the icon files of each item on the desktop. You could probably use all that information to construct a passable replica of the desktop. However, I couldn't imagine that the effect is worth the effort.
It's probably not entirely impossible. You should be able to grab an image of the current wallpaper, a list of each item on the desktop, the position of each item on the desktop, and the icon files of each item on the desktop. You could probably use all that information to construct a passable replica of the desktop. However, I couldn't imagine that the effect is worth the effort.
Well, as long as the player doesn't use any apps like Fences to change how the desktop works, then all bets are off 😛
Okay, so thats really an immense amount of effort to put in.

So I suppose the best solution would be a "fake launcher" exe-file outside of RPG-Maker that takes a screenshot and saves it - and then starts the real game.

Just thought it would be possible, because when I take a screenshot in Minecraft (Java Version) in Fullscreen via [Prt] it makes a screenshot of the desktop instead of the game. You can only make a screenshot of the game there by using the assigned in-game key bindings.
So I suppose the best solution would be a "fake launcher" exe-file outside of RPG-Maker that takes a screenshot and saves it - and then starts the real game.
See the above posts. That only possibly works presuming the launcher is the only window open on the player's screen at the time...so they aren't running the game from Steam, don't have any Web browsers or Explorer windows or anything else up...

Just thought it would be possible, because when I take a screenshot in Minecraft (Java Version) in Fullscreen via [Prt] it makes a screenshot of the desktop instead of the game. You can only make a screenshot of the game there by using the assigned in-game key bindings.
I'm not going to try to tell you what's happening with your computer when you're pressing buttons...but that seems highly dubious.

I would believe if you have multiple monitors and when you use Print Screen Windows captures everything on both of them (which might include a desktop), as opposed to the Minecraft key which only captures its own window.

But I have a hard time swallowing that it would not only not capture what's being displayed on your screen, but it would somehow capture an image that's potentially completely unrelated to all windows on your screen.
So I suppose the best solution would be a "fake launcher" exe-file outside of RPG-Maker that takes a screenshot and saves it - and then starts the real game.
If you just want a picture of the screen when the game was opened and not specifically the desktop it will be considerably simpler, and even doable with JavaScript. Though tbh it might be simpler to do that with a custom program, from what I've glanced taking screenshots with JavaScript is a bit of a pain.
In general capturing just the screen below your application should be doable, if a bit laggy, by quickly minimising it, taking a screenshot and then bringing it back up (this might be noticeable on slower computers though).

Notable thing about Minecraft is that this actually closes and reopens the game (which you can tell by it pausing when you do this). Though sometimes this kind of screenshot will just get you a black screen, or the contents of Minecraft before it was put in fullscreen - it's not exactly reliable, since this behaviour is in no way intended.
Yeah, I mean not necessarily only the desktop without anything. What I meant was just not a screenshot from the game, but from everything else.
So I think this might be a solution that it quickly minimizes, takes a screenshot and then reopens. Even if someone notices it in the blink of an eye it would not be that big of a deal. Thanks for the idea.
Minecraft's fullscreen uses "Exclusive Fullscreen" mode, which is a mode in which the application takes control of the entire display and is basically writing directly to the graphics hardware, so your operating system doesn't actually know what's being displayed. Since the Print Screen button is a function of the operating system, and the OS can't actually see what the game is doing (while it's in fullscreen), it will often display whatever was visible before the game went fullscreen.

Original thread: https://forums.rpgmakerweb.com/threads/solved-create-and-save-desktop-screenshot.162560/