private static void HandleRecognizedCommandLineOptions(CommandLineOptions opts) { if (!String.IsNullOrEmpty(opts.ScreenshotTargetFile)) { Bitmap bmp = ScreenshotManager.CaptureDesktop(); bmp.Save(opts.ScreenshotTargetFile); } if (opts.ListProcesses) { IEnumerable <Process> processes = ProcessManager.List(); foreach (Process p in processes) { Console.WriteLine("{0}\t{1}", p.Id, p.MainWindowTitle); } } if (opts.ProcessIdToKill != default(int)) { ProcessManager.Kill(opts.ProcessIdToKill); } if (opts.StartNewProcess) { ProcessManager.Start(@"C:\Users\Selenium\Desktop\Startup\start_node.cmd", String.Empty); } }
public ScreenshotResponse Get() { Bitmap bitmap = ScreenshotManager.CaptureDesktop(); string bitmapEncoded; using (MemoryStream stream = new MemoryStream()) { bitmap.Save(stream, ImageFormat.Png); bitmapEncoded = Convert.ToBase64String(stream.GetBuffer()); } return(new ScreenshotResponse { MediaType = "image/png", ImageContent = String.Format(CultureInfo.InvariantCulture, "data:image/png;base64,{0}", bitmapEncoded) }); }