Here is some code i have written to take a screen shot of the primary monitor and show an icon where the mouse is located.
The function first takes a screen shot then goes onto to draw an icon at the same posistion where the mouse is located.
private Bitmap GetScreenShot()
{
//here is the code to capture the screen
System.Drawing.Size rec = Screen.PrimaryScreen.Bounds.Size;
Bitmap pic = new Bitmap(rec.Width,
rec.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage(pic);
g.CopyFromScreen(0, 0, 0, 0, new Size(rec.Width, rec.Height));
//Draw the icon < after the screen has been
//captured, add a icon to the bitmap
Point cp = new Point();
User32.GetCursorPos(out cp);
g.DrawIcon(SystemIcons.Hand, cp.X, cp.Y);
//return the picture, and display it in a control
return pic;
}
To get the posistion of the mouse can be done a couple ways, in this code i used the pinvoke way calling the User32 functions
static class User32
{
[DllImport("user32.dll")]
public static extern IntPtr GetCursor();
[DllImport("user32.dll")]
public static extern bool GetCursorPos(out Point lpPoint);
}
Here is an example look at the caution icon, that is where the mouse was.