I have WPF application in which we wanted to achieve functionality of screenshot using code behind.
Whenever we want we should be able take screenshot of our application on user's machine (not entire print-screen)
For this I done some google and found that DllImport("user32.dll")
will help me in this regards. However, I don't have any clue how to use this? Which method I should refer here?
I tried with below code but no luck-
[DllImport("User32.dll")]
public static extern int SetForegroundWindow(IntPtr point);
Process p = Process.GetCurrentProcess();
p.WaitForInputIdle();
IntPtr h = p.MainWindowHandle;
SetForegroundWindow(h);
SendKeys.SendWait("k");
IntPtr processFoundWindow = p.MainWindowHandle;
Please suggest.