There is a WPF form. The shape has a shadow around the window. The shadow is spelled out using DropShadowEffect . WindowsStyle and others are set to none , respectively, since it is part of the window, then when you press Alt + PrintScreen, the window is copied along with the shadow, and accordingly with what is under it. How can I implement the interception of pressing this combination and copy a certain part of the window to the buffer? For example, indented on all sides by 15 pixels?
UPD: in this case, I suppose that you can not block the Alt + PrintScreen combination, but get a screenshot of the window in the usual Keystroke event in the window focus, and work with it to buffer the trimmed version into the buffer.
1 answer
Subscribing to a shortcut key, I suppose, is done in the same way as always - using the RegisterHotKey function (although I can not guarantee that the system will allow you to override the system shortcut). There is no built-in wrapper in .NET.
Screenshot creation is traditional GetDC (0). The .NET is wrapped in a Graphics.CopyFromScreen .
The system is responsible for the shadow of the windows, so you will have to take a screenshot of the part of the screen that the window takes, plus a margin for the shadow. It seems that the size of the shadow is stitched somewhere in the Aero choruses, so the size will have to be guessed by sight. Since WPF uses all sorts of smart scaling, you cannot rely on window dimensions, so I advise you to take dimensions directly from WinAPI, otherwise at a scale other than 100%, everything will slip.
True, given how much trouble it is, I would have first asked myself: is it really so necessary? It is much easier to put a white background under the window, take a screenshot of the entire screen, and then cut out the desired one. Plus there is a zoo program that will make it convenient and pleasant.
- You probably did not understand what kind of shadow was meant. The shadow is not systemic, but simulated with the help of
DropShadowEffect, and therefore inside the window. And I just need to get a screenshot of the window without this shadow, that is, to cut the screenshot "Inside". - BwehaaFox - one@BwehaaFox Well, if everything is yours, then RenderTargetBitmap can be bypassed. However, the universal way also works, only plus change to negative. - Athari