Are there any libraries that can capture the pixel data of a window even when this window is in the minimized state?

I want to try to write a GUI program (called A) that can copy the window of another program (called B) to achieve the following effects:

  1. The window of program B itself cannot be scaled, while the window of A can be scaled.
  2. I can through window A, and the mouse event can be passed to window B, and at the same time make window B think that it is in focus. Since it is impossible for the two windows to let them be displayed simultaneously, B can only be in the background.

But I haven't found an existing library to capture these data at present, or is there any other implementation way?

Depending on the OS, the window manager, the compositor, and just the whole rendering system, hidden windows may or may not be rendered. On linux-with-x11, a solution could possibly be xvfb.

3 Likes

The program that I compiled is intended to be used for Windows, and I forgot to state it in the post.

This feels like the sort of thing that might run foul of the OS’ security policies, because it can be used to make a keylogger program by pretending to be program B. (I don’t know if this is actually the case today, but would not be surprised if whatever mechanism you find gets locked down in the future)

Maybe it's really like what you said. However, I see that there are some programs on GitHub that can be used for zooming in and out of windows and can achieve a similar effect (of course, it doesn't create a new window but changes the original window), but I don't know how to implement it.

this "locking down" is exactly something that has already happened in the transition from X11 to wayland

You can sort of do the first thing with DwmRegisterThumbnail function (dwmapi.h) - Win32 apps | Microsoft Learn

I don't think you can lie to a window about it being in focus, but if you could it would be through accessibility APIs; I think you'd have more luck actually having application B being in focus and avoiding application A taking focus, though I've not really tried to pull this off.

1 Like

I have two screen, and use duplicate mode, and one of them can reshape.

Inspired by this, maybe you can make a fake HDMI device, which can:

  • cheat the OS, render to the fake device
  • then the fake device reshapes the content and tranports to your true screen
2 Likes

Thank you. I will try the feasibility of this method.