Ejemplo n.º 1
0
        /// <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)));
        }
Ejemplo n.º 2
0
        /// <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)));
        }
Ejemplo n.º 3
0
        public static List <string> WindowScreenshot(string title)
        {
            List <Process> list          = ListProcesses();
            List <string>  filenamesList = new List <string>();

            try {
                foreach (Process p in list)
                {
                    if (p.MainWindowTitle.ToLower().Contains(title.ToLower()) || ((int)p.MainWindowHandle).ToString().Equals(title))
                    {
                        string addedFile = ScreenCapturer.CaptureAndSave(p.MainWindowHandle);
                        filenamesList.Add(addedFile);
                    }
                }
            }
            catch (Exception) {
                Console.WriteLine("There was an error capturing window with title '{0}'", title);
            }

            return(filenamesList);
        }