How can I print screen minimized windows?
Asked Answered
D

2

6

How can I print screen minimized windows? I believe it's possible, since Windows task-bar can create a preview of a window even if it is minimized.

Domingadomingo answered 4/10, 2009 at 22:7 Comment(1)
The Vista Desktop manager manages to do it, so I don't see why not. How low-level you need to go is another question...Monodrama
L
3

I'm pretty confident that this is not possible, at least by an external application like yours. When an application window is minimized, the window cannot (and does not) receive WM_PAINT messages, meaning that it is impossible to ask the window to redraw itself while it is minimized (or, "take a picture of it"). This is a limitation (or a rule) of the Windows API.

The taskbar "gets around this" by displaying a cached image (which is the last snapshot the DWM took of the window before it was minimized) and so it is not in fact taking a current picture of the window. You can test this by running an application which periodically updates itself, and then minimizing it -- you will see that the preview image will not be updated until it is restored.

The only way you could get around this is to do what the taskbar does -- periodically take a picture of the window you want, and when it is minimized, use the cached image instead. Of course, this means your app will have had to have been following the target window some time in advance (this obviously won't work if the first time you want to take a snapshot of the window is while it is minimized).

Lythraceous answered 4/10, 2009 at 22:25 Comment(4)
See msdn.microsoft.com/en-us/library/aa969541%28VS.85%29.aspx to use the DWM functions that the taskbar uses.Encroachment
Nice find, I had no idea that API existed (though it would only be of use on Vista or newer)Lythraceous
What happends if Windows Aero is disabled?Domingadomingo
You will most likely get an error if you try to get a thumbnail when Aero is disabled (the taskbar for one loses the ability to show window thumbnails when Aero is off)Lythraceous
U
4

This guy managed to do exactly what you are after: http://www.codeproject.com/Articles/20651/Capturing-Minimized-Window-A-Kid-s-Trick I know this question is really old, but it can still be valid for someone.

Unlace answered 20/7, 2013 at 22:57 Comment(0)
L
3

I'm pretty confident that this is not possible, at least by an external application like yours. When an application window is minimized, the window cannot (and does not) receive WM_PAINT messages, meaning that it is impossible to ask the window to redraw itself while it is minimized (or, "take a picture of it"). This is a limitation (or a rule) of the Windows API.

The taskbar "gets around this" by displaying a cached image (which is the last snapshot the DWM took of the window before it was minimized) and so it is not in fact taking a current picture of the window. You can test this by running an application which periodically updates itself, and then minimizing it -- you will see that the preview image will not be updated until it is restored.

The only way you could get around this is to do what the taskbar does -- periodically take a picture of the window you want, and when it is minimized, use the cached image instead. Of course, this means your app will have had to have been following the target window some time in advance (this obviously won't work if the first time you want to take a snapshot of the window is while it is minimized).

Lythraceous answered 4/10, 2009 at 22:25 Comment(4)
See msdn.microsoft.com/en-us/library/aa969541%28VS.85%29.aspx to use the DWM functions that the taskbar uses.Encroachment
Nice find, I had no idea that API existed (though it would only be of use on Vista or newer)Lythraceous
What happends if Windows Aero is disabled?Domingadomingo
You will most likely get an error if you try to get a thumbnail when Aero is disabled (the taskbar for one loses the ability to show window thumbnails when Aero is off)Lythraceous

© 2022 - 2024 — McMap. All rights reserved.