Take Screenshot of entire screen or other window

Godot Version

4.1.3

Question

Hello! I am making a game and I want to know how I can take screenshots of an entire screen, or even just a window that isn’t the game window. How would I go about doing this?

use this get_texture

the implementation code:
https://www.reddit.com/r/godot/comments/12dxv7i/screenshotting_in_godot_40_changed/

Thanks for the quick reply!
However that isn’t what I’m looking for. That method is limited to the game window only, and I want to get the entire screen or specific window on screen.

Such a feature would have security implications, because it would allow taking screenshots for example of account information or private photos in other applications.
I’m unsure, if Godot should support such a feature in the first place.
Also take the Wayland display server: it encapsulates windows from each other, so on that platform you could not even take screenshots of other windows by design.