12
Estoy usando el siguiente código para capturar la pantalla en un mapa de bits. La pantalla se captura, pero no puedo obtener el puntero del mouse en la pantalla. ¿Podría sugerir algún enfoque alternativo para que también se capture el mouse?Cómo capturar la pantalla y el puntero del mouse con las API de Windows?
private Bitmap CaptureScreen()
{
// Size size is how big an area to capture
// pointOrigin is the upper left corner of the area to capture
int width = Screen.PrimaryScreen.Bounds.X + Screen.PrimaryScreen.Bounds.Width;
int height = Screen.PrimaryScreen.Bounds.Y + Screen.PrimaryScreen.Bounds.Height;
Size size = new Size(width, height);
Point pointOfOrigin = new Point(0, 0);
Bitmap bitmap = new Bitmap(size.Width, size.Height);
{
using (Graphics graphics = Graphics.FromImage(bitmap))
{
graphics.CopyFromScreen(pointOfOrigin, new Point(0, 0), size);
}
return bitmap;
}
}
agradable, limpio y rápido código. Gracias. –
Tenga en cuenta que este código dibujará algunos cursores en la posición incorrecta, ya que debe llamar a 'GetIconInfo' para los desplazamientos. También algunos aparecerán desvanecidos, para más detalles ver: http://stackoverflow.com/questions/918990/ – WhoIsRich