I'm using BitBlt
winapi function to take a screenshot of a given window, even if the window is partially overlapped.
I have everything working fine already, except that, on Windows 10, for some windows (like the Edge browser) the screenshot turns out completely black.
A number of other questions concur on attributing this problem to the use of a hardware-accelerated graphics context on those windows.
- BitBlt screen capture not working on Windows 10
- Screenshot with BitBlt results in black image on Windows 10
- Screenshot captured using BitBlt in C# results a black image on Windows 10
- BitBlt not capturing windows in Hardware accelerated mode
- AutoHotkey-GDIp: Capture a screenshot from a hardware accelerated window
Apparently the GDI library is incompatible with that kind of graphics context so a different library has to be used.
My question is specifically about how to detect if a window is using a graphics context that's incompatible with the GDI library.
If I'm able to detect this, then I can choose which library to use for capturing the screenshot correctly (GDI, ActiveX or other).
Otherwise, the only way I could detect this is by scanning the screenshot pixel by pixel to check that's completely black. Then using a different capture method till I get some content on the screenshot.
But this sounds like an awful solution.
GetDC(nullptr)
and then clip out the target window. – GaliotPrintWindow
withPW_RENDERFULLCONTENT
as suggested in the answer to the related question? – IdentityPW_RENDERFULLCONTENT
trick is indeed able to capturing hardware-accelerated windows. Although not an answer to the question, it's a useful workaround for Windows 10. – Countermove