none
Remote desktop - Screen capture and Recording

    Question

  • Hi,

       We have Visual Studio Team Foundation Server 2010.

    In MTM, while running the test there is option to take the screen shot. We have application running in remote desktop. We will be running the MTM in local system. From here we would like to capture the screen shot of the application running in remote desktop. We also like to record the test for later playback. Are these options are possible in MTM or not?

    Thank you,

    Tuesday, August 30, 2011 10:46 AM

Answers

  • The built in screenshot tool will still work but the windowed version would include the whole remote desktop window. The rectangle one works fine though.  I think the video should be the same, you might have to run the remote desktop session in windows mode rather than full screen though

    Wednesday, September 07, 2011 6:51 AM

All replies

  • You can use the following code to take a screen shot of the test run on the remote desktop,

     

     

    /// <summary> 
      /// Take screen shot 
      /// </summary> 
      /// <param name="left">left</param> 
      /// <param name="top">top</param> 
      /// <param name="width">width</param> 
      /// <param name="height">height</param> 
      /// <returns>screen shot in bytes</returns> 
      public static byte[] TakeScreenShot(int left, int top, int width, int height) 
      { 
       // Set the bitmap object to the size of the screen 
       var bmpScreenshot = new Bitmap(width, height, 
                 PixelFormat.Format32bppArgb); 
     
       // Create a graphics object from the bitmap 
       var gfxScreenshot = Graphics.FromImage(bmpScreenshot); 
     
       // Take the screenshot from the upper left corner to the right bottom corner 
       gfxScreenshot.CopyFromScreen(left, top, 0, 0, 
                new Size(width, height), CopyPixelOperation.SourceCopy); 
     
       var buffer = new byte[bmpScreenshot.Size.Height * bmpScreenshot.Size.Width * 4]; 
     
       var stream = new MemoryStream(buffer); 
     
       bmpScreenshot.Save(stream, ImageFormat.Png); 
     
       return stream.ToArray(); 
      } 
    
    

     

    Or Save the screen shot to a certain location

    Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width,          Screen.PrimaryScreen.Bounds.Height);
    
    Graphics graphics = Graphics.FromImage(bitmap as Image);
    
    graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size);
    
    bitmap.Save(@"c:\temp\screenshot.bmp", ImageFormat.Bmp);

     

    HTH
    Cheers, Tarun


    Please remember to mark the replies as answers if they help.

    Tarun Arora

     

    Blog: http://geekswithblogs.net/TarunArora  Subscribe in a reader


    • Edited by Tarun__AroraMVP Tuesday, August 30, 2011 12:29 PM Added more infor
    Tuesday, August 30, 2011 12:27 PM
  • The built in screenshot tool will still work but the windowed version would include the whole remote desktop window. The rectangle one works fine though.  I think the video should be the same, you might have to run the remote desktop session in windows mode rather than full screen though

    Wednesday, September 07, 2011 6:51 AM
  • oh if your talking about action recordings so you can use the fast forward feature this is not going to be possible. MTM needs access to the controls which it can't do through remote desktop
    Wednesday, September 07, 2011 6:54 AM