Note that there are some explanatory texts on larger screens.

plurals
  1. POCapture Screenshot as a scheduled task on a server using c#
    primarykey
    data
    text
    <p>I had written the following c# code and would like to run it as a scheduled task on a server. However I get exception due to this part of the code. I am assuming that the error has got to do with fact that there is no screen. Has anybody found a way to capture the screen as a scheduled task and not connected to the remote system?</p> <pre><code>Bitmap bt; // a browser is running for which screen shot needs to be taken. bt = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format24bppRgb);//use 24bbp for capture image as AForge supports only 24bpp. Graphics screenShot = Graphics.FromImage(bt); screenShot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy); bt.Save(@"C:\folder\test.png", ImageFormat.Png); </code></pre> <p>since i am running it on a server it has no physical monitor attached to it i have to remote to the server. When i run it manually there is no error. However when i schedule it and log off from the machine it gives me the below message</p> <pre><code>Application: ConsoleAppCaptureScreenshot.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.ComponentModel.Win32Exception Stack: at System.Drawing.Graphics.CopyFromScreen(Int32, Int32, Int32, Int32, System.Drawing.Size, System.Drawing.CopyPixelOperation) at ConsoleAppCaptureScreenshot.Program.Main(System.String[]) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload