Created
March 17, 2011 20:06
-
-
Save OrigamiTech/875026 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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