Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

268
Views
Tome una captura de pantalla de parte de la pantalla en C #

Quiero tomar una captura de pantalla de una parte específica de un sitio web usando C# o .net Code, no puedo crear una aplicación de formulario de Windows porque debe estar incrustada en otra cosa.

Esto es lo que tengo hasta ahora:

 using System.Drawing.Imaging; using System.Drawing; using System; using System.Windows.Forms; try { //Creating a new Bitmap object Bitmap captureBitmap = new Bitmap(1024, 768, PixelFormat.Format32bppArgb); //Bitmap captureBitmap = new Bitmap(int width, int height, PixelFormat); //Creating a Rectangle object which will //capture our Current Screen Rectangle captureRectangle = Screen.AllScreens[0].Bounds; //Creating a New Graphics Object Graphics captureGraphics = Graphics.FromImage(captureBitmap); //Copying Image from The Screen captureGraphics.CopyFromScreen(captureRectangle.Left,captureRectangle.Top,0,0,captureRectangle.Size); //Saving the Image File (I am here Saving it in My E drive). captureBitmap.Save(@"E:\Capture.jpg",ImageFormat.Jpeg); //Displaying the Successfull Result MessageBox.Show("Screen Captured"); } catch (Exception ex) { MessageBox.Show(ex.Message); }

Este código funciona bien mientras estoy creando una aplicación de formulario de Windows, pero tan pronto como lo cambio a la consola, no funciona incluso después de agregar "usando System.Windows.Forms;" y me produce este error:

 //Screen does not exist in the current context

Entonces, ¿hay alguna solución para esto o cualquier otra forma en que pueda tomar una captura de pantalla de una parte específica de un sitio web mediante programación sin conectarme a él en absoluto?

Gracias por adelantado.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

De hecho, encontré una respuesta un minuto después de publicar desde los enlaces sugeridos "que, por cierto, no se mostraron en la búsqueda que hice durante 2 días por algún motivo", pero de todos modos

es esta pregunta

y es tan simple como

 Rectangle rect = new Rectangle(0, 0, 100, 100); Bitmap bmp = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb); Graphics g = Graphics.FromImage(bmp); g.CopyFromScreen(rect.Left, rect.Top, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy); bmp.Save(fileName, ImageFormat.Jpeg);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!