Screenshot of Hidden Window

前端 未结 2 1839
伪装坚强ぢ
伪装坚强ぢ 2020-12-21 08:54

I need to take a screenshot of a currently hidden window without giving focus to that window. I saw a post on this, here: Window screenshot using WinAPI

I\'ve never

相关标签:
2条回答
  • 2020-12-21 09:12

    It's hard to imagine that you could have one solution that would work on Windows and OS X. The windowing frameworks are completely different. It would be harder to try to come up with one solution that to write two.

    On Windows at least, I'm not convinced you'll have much luck taking a screenshot of a hidden or obscured window. When you search for this on the web, there are a gazillion hits for people asking that very question. None of them appear to have succeeded. If you factor in DWM and Aero glass then I think your chances of success are limited.

    0 讨论(0)
  • 2020-12-21 09:13

    I would investigate the possibility of asking the window to draw itself into a bitmap, rather than trying to take its picture with a screenshot. That might be a way of making it irrelevant that the window is minimized. Something like the WM_PRINT or WM_PRINTCLIENT message. I suspect that's actually what the person was trying to do who asked the original question that you linked to. The biggest pitfall is if the window doesn't handle that message appropriately. Not all apps are so well-behaved. Also, I don't think it works for windows that are truly hidden, but I can't tell from your question and the flurry of articles you link to whether or not that's a real concern.

    Unfortunately, I also know nothing about programming OS X; I'm just a user on that platform. You might try diving into the Qt sources to see how they're doing it cross-platform, if that's really important to you.

    0 讨论(0)
提交回复
热议问题