none
Screen capture service/app on remote desktop

    Question

  • Hi,
    I need to make an application that will automatically capture the screen, every 10 seconds. It needs to run on one of our servers. This is, of course, no problem, but i would like to run it as a service. 
    • So, question 1: Is this at all possible?
    I would assume it isn't possible, as a service. This is why i have made a simple winform app, that does it. BUT, even with this, i am having some problems.
    We administrate the server via remote desktop, and only use a single session (we all log on with /console). This session, is what i would like to screen capture.
    However, when i close (i do not log off) the remote desktop application, it seems my program stops running. Screenshots are no longer saved, and it throws no exceptions. I would expect an exception to be thrown, if it didn't like me closing the remote desktop.

    • So question 2: Am i missing something, when it is on a /console server? Does it stop executing something? We already run a bunch of other winform programs, that act as servers, and they are running fine.
    I am not sure i explained well enough, or if this is even the right forum for this. 
    If you need any more information, just let me know.

    Nicolai Søndergaard LM Glasfiber A/S
    Tuesday, March 16, 2010 1:25 PM

Answers

All replies

  • My terminal server is displaying the log on screen.

    I log on to the terminal server remotely and the terminal server screen doesn't change.

    Which screen do you want to capture?  The terminal server screen or the screen displayed to the remote desktop.

    Tuesday, March 16, 2010 2:14 PM
  • I want to capture the screen displayed on the remote desktop.
    It captures it fine, when i have the remote desktop connection open, but stops doing anything, when i close it, even though the windows session is still running.

    Nicolai Søndergaard LM Glasfiber A/S
    Tuesday, March 16, 2010 2:21 PM
  • Hi Nicoolai

    Would you mind giving the code snippet?

    I used the following code to capture a single screenshot in a Winform app(via Remote desktop), it works fine:

            public Bitmap ScreenCapture()

            {

                Rectangle screenShot;

                Bitmap sBit;

     

                //Drawing a Rectangle

                screenShot = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;

     

                //Set image size and format

                sBit = new Bitmap(screenShot.Width, screenShot.Height, PixelFormat.Format32bppArgb);

                Graphics sGraphic = Graphics.FromImage(sBit);

     

                //Capture From Screen

                sGraphic.CopyFromScreen(screenShot.Left, screenShot.Top, 0, 0, screenShot.Size);

     

                return sBit;

            }


    Thanks.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, March 18, 2010 9:01 AM
  • Figo, i am doing the same thing, and it does work fine, UNTILL i close the remote desktop client.

    I have a timer running, on the winform, and i would expect it to keep running, after i close the remote desktop client, but it doesn't seem to do it.

    Nicolai Søndergaard LM Glasfiber A/S
    Thursday, March 18, 2010 3:03 PM
  • Hi Nicoolai,

    I also put a Windows.Forms.Timer and remote destop to test, and there is no problem, can you please help provide more code and environment info so that I can reproduce the problem?

    Thanks.


    Figo Fei
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com 


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Friday, March 19, 2010 1:56 AM
  • Hi Nicoolai,

    I also put a Windows.Forms.Timer and remote destop to test, and there is no problem, can you please help provide more code and environment info so that I can reproduce the problem?

    Thanks.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, March 19, 2010 1:57 AM
  • Oh, so it keeps capturing, even after you close the remote desktop application?

    When i close the remote desktop, it stops creating the screenshot.png. When i connect to the server again, it resumes. No messagebox is waiting for me with an exception.

     

    My app is running on a windows 2003 server SP2. The remote desktop session is with /console and /admin.

    This is my timer code:

                try
                {
                    Bitmap bmpScreenshop = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
                        Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
                    Graphics gfxScreenshot = Graphics.FromImage(bmpScreenshop);
                    gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
                        Screen.PrimaryScreen.Bounds.Y, 0, 0,
                        Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
                    string strSaveFile = @"\\dk-lm0750\QLIKVIEWIMAGES_TO_SHAREPOINT\ServerDaemon\" +
                        "Screenshot.png";
                    bmpScreenshop.Save(strSaveFile, ImageFormat.Png);
                }
                catch (Exception Excp)
                {
                    MessageBox.Show(Excp.ToString());
                }


    Nicolai Søndergaard LM Glasfiber A/S
    Friday, March 19, 2010 7:03 AM
  • Actually, there IS an exception, i just didn't see it because the form was hidden.

    I get a handle is invalid, so i assume the PrimaryScreen is gone, when i close the remote desktop.


    Nicolai Søndergaard LM Glasfiber A/S
    Friday, March 19, 2010 7:15 AM
  • It seems you're going to capture another session of the Windows login's screen, right? That could be a problem, and I've not tested yet, but it sounds going to break the security sandbox.

    Thanks.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, March 19, 2010 7:37 AM
  • I have come across this thread, which seems to fix it.

    However, i am not too sure i dare to implement this. 

    http://www.vbforums.com/showthread.php?p=3657773


    Nicolai Søndergaard LM Glasfiber A/S
    • Marked as answer by Figo Fei Monday, March 22, 2010 3:02 AM
    Friday, March 19, 2010 8:21 AM