There is a task to capture certain (selected by user for example) windows in Windows 10, ideally it should be possible to capture the selected window without capturing anything extra, in particular, if any other window overlaps the window that we are capturing, this overlapping window is not should be captured. I tried to look for various APIs that could help in solving this task, however, unfortunately, so far no API has been able to reliably do this.

The most popular way that is mentioned everywhere is to use GDI and the GetDC() / GetWindowDC() together with BitBlt() . This approach worked fine with Aero enabled on Windows 7 and on applications like Notepad in Windows 10, but the problem is that Metro UI Apps is not captured in this way, the resulting bitmap is just black and contains nothing. Everything is complicated by the fact that most popular applications (browsers for example) change the way they render to Windows 10, so things like Google Chrome, Mozilla Firefox latest versions are not captured using this approach too (however, they are captured in previous versions of Windows). In a word, BitBlt() as an API has become very unpredictable to work in Windows 10, some windows are captured, some windows are captured partially (the title part is not captured, the contents of the windows under the window being captured are captured), and if you try to capture, for example, Mozilla Firefox, the resulting bitmap will generally contain only the contents of the windows that are under the Mozilla Firefox window.

I also tried using PrintWindow() and PrintWindow() in conjunction with BitBlt() , but I could not solve the problem.

Other possible capture methods are described here , but they also seem to be inappropriate (it seems that other methods do not distinguish between windows as such and can only capture the full screen or parts of this screen).

It seems to me that there should be a reliable way of capturing such applications, since TeamViewer, for example, somehow captures them.

    1 answer 1

    First, transfer the focus to the window, move it to a corner, take a screenshot of the entire screen, cut, return the windows as they were. Sample code here> https://github.com/miranda-ng/miranda-ng/blob/master/plugins/SendScreenshotPlus/src/Utils.cpp (CaptureWindow function with bIndirectCapture = true)

    • Thanks for the advice. Is it possible to somehow see how this function works in action? I suppose that if it is in miranda sors, can it somehow be activated? I tried to install this IM client, but did not find where to try this feature. Could you tell? The fact is that I check how reliable and “fast” it works (it should be invisible to the user), but the approach is interesting. - Programmer
    • one
      MirandaNG + plugin SendScreenshotPlus, the main menu will be able to take screenshots. It works completely unnoticed. - Mikalai Ramanovich
    • I tried, in the current state, the plugin could not capture the "Metro UI application", but I believe this is for the reason that it is being captured from the DC window, and not from the DC screen. The fact is that I need to be sure that with this approach I will be able to capture a window with FPS ~ 15 and there will be no visible jumps of focus between the windows, i.e. will not be disturbed by ux. - Programmer
    • It was necessary to put a checkbox "Indirect capture" (Indirect) to capture Metro UI and all browsers. But at the expense of 15fps it is unlikely, then you need a different approach. - Mikalai Ramanovich