i would like to take a screenshot for a form of an opened application which is not on top without bringing this app on top to capture screenshot of the form ! i want to do it on C# i have searched a lot and i found nothing. would you please give any code hints?
Asked
Active
Viewed 2,061 times
1
-
If a "screenshot" is an image of all or part of a screen, then how do you suppose this would work? – STLDev Nov 02 '17 at 20:56
-
thank you guys i will edit my question right now – Ahmed Sherif Nov 02 '17 at 21:00
-
This sounds like it will involve UI Automation and/or an accessibility API. Which operating systems are you interested in? – jpaugh Nov 02 '17 at 21:29
1 Answers
0
The PrintWindow API (MSDN) method can do that. You can use the API from C# using P/Invoke. The website pinvoke.net has the definition you need.
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool PrintWindow(IntPtr hwnd, IntPtr hDC, uint nFlags);
You'll need a window handle which you can get like in this SO answer.

Thomas Weller
- 55,411
- 20
- 125
- 222