Desktop Capture

Ask general questions here.
theraviz
Posts: 9
Joined: Sun Apr 14, 2019 9:46 am

Desktop Capture

Post by theraviz » Sun Apr 14, 2019 10:28 am

Hello,

I want to capture desktop screenshot frequently during my automation execution and save it in a particular folder. My code is all working except the one to capture the desktop which is the below.

Image img = Microsoft.VisualStudio.TestTools.UITesting.UITestControl.Desktop.CaptureImage();
img.Save(_path, System.Drawing.Imaging.ImageFormat.Jpeg);

The first code is not working even though I have added the proper reference. It says

Could not load file or assembly 'Microsoft.VisualStudio.TestTools.UITest.Playback, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Is there a way to solve this? Or can you provide me an alternate code just to capture the full desktop?

Thanks in advance

theraviz
Posts: 9
Joined: Sun Apr 14, 2019 9:46 am

Re: Desktop Capture

Post by theraviz » Mon Apr 15, 2019 1:05 pm

This is resolved using bitmap codes from the earlier posts. Thanks