Skip to content

Instantly share code, notes, and snippets.

@OrigamiTech
Created March 17, 2011 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OrigamiTech/875026 to your computer and use it in GitHub Desktop.
Save OrigamiTech/875026 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.IO;
namespace Screenie
{
class Program
{
static string targetDir = Path.Combine(new string[] { Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "My Dropbox", "Public", "screens/" });
// or a 'screens' folder under your personal dropbox public folder.
[STAThread]
static void Main(string[] args)
{
if (!Directory.Exists(targetDir))
Directory.CreateDirectory(targetDir);
for (int i = 0; i < Screen.AllScreens.Length; i++)
{
Screen screen = Screen.AllScreens[i];
DateTime dt = DateTime.Now;
string fileName = (Screen.AllScreens.Length > 1 ? ("[" + i + "]_") : "") + dt.Year.ToString("0000") + "_" + dt.Month.ToString("00") + "_" + dt.Day.ToString("00") + "_" + dt.Hour.ToString("00") + "_" + dt.Minute.ToString("00") + "_" + dt.Second.ToString("00") + ".png";
using (Bitmap bmpScreenshot = new Bitmap(screen.Bounds.Width, screen.Bounds.Height, PixelFormat.Format32bppArgb))
{
using (Graphics gfxScreenshot = Graphics.FromImage(bmpScreenshot))
gfxScreenshot.CopyFromScreen(screen.Bounds.X, screen.Bounds.Y, 0, 0, screen.Bounds.Size, CopyPixelOperation.SourceCopy);
bmpScreenshot.Save(Path.Combine(targetDir, fileName), ImageFormat.Png);
}
if (i == 0)
Clipboard.SetText("http://dl.dropbox.com/u/[YOUR DROPBOX ID]/screens/" + fileName);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment