It seems to be pretty problematic to get a full screenshot out of any window/application.
With the Win32 API I was almost able to archive that, it struggles as it is limited to from which windows it can get image data from - from some windows its impossible (From what I know).
With other methods any window can be screenshotted, but only the parts that are visible on the main screen. A window that is only half in screen results in a screenshot of only the area which is on the screen.
First I've tried it with c++ and the Win32 API according to this example: https://learn.microsoft.com/en-us/windows/win32/gdi/capturing-an-image
I added a window specification and made some adjustments as the example is for the whole screen.
HWND hWnd = FindWindow(NULL, windowTitle);
It works very well - but not for all windows. This answer seems to give the answer why it doesn't work on all windows.
C++ WinAPI screenshot of a window in the background
I gave up on the Win API and tried it with some python libraries. pyautogui and PTL.
They work super easy. However once the window exceeds the screen boundaries, only the part of the window is screenshotted, which lays inside the computer screen.