I just released a new screen capture utility for BugTracker.NET. With it, with just 2 clicks (2 clicks!) you can capture a screenshot and post it to your BugTracker.NET. Just click "Capture" and then click "Send".
The screen capture utility looks like this:
You can annotate the screen capture before you send it with a red "Sharpie" and provide a description. You can have it create a new bug or post it to an existing bug.
This new app is a rewrite of one I did 5 years ago. That earlier app was...ok. It did the job. But then, a couple years ago, Alexej Hirsch developed a new screen capture app, "Bug Shooting", that could talk to BugTracker.NET and several other trackers. Bug Shooting was much nicer than my old app, and it used a newer, better API - an API that Alexej himself pushed me to develop. There wasn't much point in trying to compete with him, so, I abandoned my own app and started recommending that people use his. That was the story for a couple years.
This month, however, Alexej released a new version of Bug Shooting as 30-day-trial shareware. I really, truly wish him the best of luck, because his app is really nice and he has earned whatever money he can make from it. But, I wanted BugTracker.NET to come with a free app, so I decided to try to revamp the screen capture part.
That earlier app was written using C++/MFC, created using Visual Studio 2005. I don't even have that installed on my home computer, and I really didn't look forward to returning to MFC development. I've worked with MFC for years. I used to be really good at it. Then, about 3 years ago I started a new assignment at my real job using C#/.NET/WinForms. Despite being so experienced at MFC and so new to WinForms, I felt like after, oh, 2 days, I was more productive with WinForms than with MFC. This screen capture app here, starting from scratch, I got a barebones but fully usable version done in about 6 hours, including region selection, annotation, sending to the tracker. Wow, I even impressed myself! What you see in the screen shot, that only took about 12 hours.
The MFC years weren't wasted, nor the Petzoldian-Win32 years before those; that Win32 knowledge still comes in handy, even with WinForms. This screen capture app too uses native Win32 calls here and there.
If you use the new app, please let me know how it goes, good or bad.
If you are looking to write your own screen capture app and want a very simple starting point, the source code comes with the BugTracker.NET zip file,
The rest of this post consists of code snippets demonstrating some of the key APIs you would use for this type of app.
* Capture a portion of the screen as a bitmap:
// Size size is how big an area to capture
// pointOrigin is the upper left corner of the area to capture
Bitmap bitmap = new Bitmap(size.Width, size.Height);
using (Graphics graphics = Graphics.FromImage(bitmap))
graphics.CopyFromScreen(pointOrigin, new Point(0, 0), size);
* Get the extents of a multiple monitor desktop
int maxX = 0;
int maxY = 0;
foreach (Screen screen in System.Windows.Forms.Screen.AllScreens)
int x = screen.Bounds.X + screen.Bounds.Width;
if (x > maxX)
maxX = x;
int y = screen.Bounds.Y + screen.Bounds.Height;
if (y > maxY)
maxY = y;
* To save the bitmap as a jpeg
if ((fileStream = saveFileDialog1.OpenFile()) != null)
* To convert the bitmap into jpg, in memory
System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
* To save the bitmap to the clipboard on Ctrl-C
private void MainForm_KeyUp(object sender, KeyEventArgs e)
if (e.KeyCode == Keys.C)
if (e.Modifiers == Keys.Control)
if (bitmap != null)
* To get the rectangle of the foreground window
static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll", SetLastError = true)]
static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect);
private struct RECT
public int Left;
public int Top;
public int Right;
public int Bottom;
IntPtr hWnd = GetForegroundWindow();
RECT rect = new RECT();
GetWindowRect(hWnd, ref rect);