locked
Screenshot without a screen RRS feed

  • Question

  • Hello everybody!
    Is it possible to take a screenshot without a screen? - Without Log
    I have a server, and when something happens, the program sends an email with the info, but would be very helpfull if the mail comes with "printscreen", of course, there not such a thing like a screen.
    I tried with this.

    using System.Net.Mail ;
    using System.Net ; 
    using System.Drawing.Imaging ;
    using System.IO ;
    using System.Windows.Forms ;

    Bitmap printscreen = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
    Graphics graphics = Graphics.FromImage(printscreen as Image);
    graphics.CopyFromScreen(0, 0, 0, 0, printscreen.Size);
    printscreen.Save(path1   + AditionalName + ".jpg", ImageFormat.Jpeg);

    It works when I am logged.... but nothing happens when not.
    Regards
    Thursday, June 16, 2016 5:41 PM

Answers

  • There is no screen to take a picture of if no one is logged in.  Every user in the system has their own desktop.  No user = no desktop.

    I'm still confused as to why you think the desktop is going to show any of the things you mentioned. If a user isn't logged in, none of that will exist.  Services cannot interact with the desktop and therefore no processing running in the system will have a UI until a user logs in. At that point only that user has a desktop so remotely getting it wouldn't work unless you used remote desktop or something to connect to it.

    If you need to show some image then just generate an image of some static data you might want to capture (machine name, etc) and then render it.  An actual image of the desktop does not exist outside of the logged in user.

    • Proposed as answer by Christopher84 Friday, June 17, 2016 6:05 PM
    • Marked as answer by DotNet Wang Monday, June 27, 2016 9:38 AM
    Friday, June 17, 2016 5:46 PM

All replies

  • Each user has their own desktop. Print screen only makes sense in the context of a user. If no one is logged in then there is no desktop to take a screenshot of.  Services run in a special session and they do have a desktop but taking a screenshot of that doesn't make any sense.

    What benefit are you thinking you'll get with a screenshot? Error messages and whatnot should already be logged either by the application or in the Event Log so using this feature for errors isn't useful.

    Michael Taylor
    http://www.michaeltaylorp3.net

    Thursday, June 16, 2016 7:28 PM
  • You need a interactive desktop session to make a screenshoot off.
    Interactive desktop sessions do not need a monitor, but they need a user loged in somehow (directly or via remote access). I am not 100% sure what happens if the user locked his session, but it should continue to work (showing the unlocked desktop underneath).

    By default Windows Services (and anything running as one like Webservers) do not run in interactive sessions. All attempts to make a screenshootwill get a default grey image.
    Interactive Services (Windows)

    If you need a screenshoot about the only way is to stop using a Service (as the override is not recommended). The Windows Task Sheduler is pretty good at this stuff and is even used by MS to replace many services nowadays (wherever possible).


    Thursday, June 16, 2016 7:32 PM
  • Well. I need to show me an image when i am not logged to the server.  
    I need an image because the program is for automatic trading. so, the image could give me errors, the spreads, event log, the chart trading, etc. and it would be complementary (the mail already show me the event log).

    Maybe convert the form from the memory to  image?
    • Edited by Juglar Friday, June 17, 2016 5:30 PM
    Friday, June 17, 2016 5:28 PM
  • There is no screen to take a picture of if no one is logged in.  Every user in the system has their own desktop.  No user = no desktop.

    I'm still confused as to why you think the desktop is going to show any of the things you mentioned. If a user isn't logged in, none of that will exist.  Services cannot interact with the desktop and therefore no processing running in the system will have a UI until a user logs in. At that point only that user has a desktop so remotely getting it wouldn't work unless you used remote desktop or something to connect to it.

    If you need to show some image then just generate an image of some static data you might want to capture (machine name, etc) and then render it.  An actual image of the desktop does not exist outside of the logged in user.

    • Proposed as answer by Christopher84 Friday, June 17, 2016 6:05 PM
    • Marked as answer by DotNet Wang Monday, June 27, 2016 9:38 AM
    Friday, June 17, 2016 5:46 PM