/// <summary> Capture a specific window (or control) and save it to a specified file. </summary> /// <param name="filename">Filename. /// <para>* If extension is omitted, it's calculated from the type of file</para> /// <para>* If path is omitted, defaults to %TEMP%</para> /// <para>* Use %NOW% to put a timestamp in the filename</para></param> /// <param name="handle">hWnd (handle) of the window to capture</param> /// <param name="format">Optional file save mode. Default is PNG</param> public static string CaptureAndSave(IntPtr handle, string filename = null, ImageFormat format = null) { if (filename == null) { filename = ScreenCapturer.RandomFilename(); } return(ImageSave(filename, format, Capture(handle))); }
/// <summary> Capture Active Window, Desktop, Window or Control by hWnd or .NET Contro/Form and save it to a specified file. </summary> /// <param name="filename">Filename. /// <para>* If extension is omitted, it's calculated from the type of file</para> /// <para>* If path is omitted, defaults to %TEMP%</para> /// <para>* Use %NOW% to put a timestamp in the filename</para></param> /// <param name="mode">Optional. The default value is CaptureMode.Window.</param> /// <param name="format">Optional file save mode. Default is PNG</param> public static string CaptureAndSave(string filename = null, CaptureMode mode = CaptureMode.Window, ImageFormat format = null) { if (filename == null) { filename = ScreenCapturer.RandomFilename(); } return(ImageSave(filename, format, Capture(mode))); }