Hi Naveen,
I got into developing this feature since a screenshot is required quite often by us. I believe that the ability to capture screenshot on errors is implemented in the version 6.
You can still explore the 'Image Manipulation' VBO and let me know if you find anything suitable.
Follow the below steps to create a new Action in the existing VBO:
Take a backup of 'Utility - Image Manipulation' xml file from the Blue Prism's VBO folder
1. Open the 'Initialise' tab -> 'Code Options' tab of the 'Utility - Image Manipulation'
- Add this path to the External References. (Must be at the same location but locate it on your machine)
C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll
2. Add a new tab and name it 'GetScreenshot' (or anything that you would like which shows in the Actions dropdown)
- Add a Code stage say 'Capture Screenshot'
- For the Start Input parameters of 'GetScreenshot', refer 1.jpg
- Refer 2.jpg for Input parameters of the Code stage
Add the necessary data items wherever required as you keep seeing them in the screenshots.
- Refer 3.jpg for Output parameters of the Code stage
- Add the below code in the 'Code' tab of the Code stage
Dim area As Rectangle
Dim capture As System.Drawing.Bitmap
Dim graph As Graphics
area = My.Computer.Screen.Bounds
capture = New System.Drawing.Bitmap(area.Width, area.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
graph = Graphics.FromImage(capture)
graph.CopyFromScreen(area.X, area.Y, 0, 0, area.Size, CopyPixelOperation.SourceCopy)
FullSavedScreenshotPath = OutputFolderPath & Format(now, "dd-MMM-yy hh-mm-ss") & ".jpeg"
capture.Save (FullSavedScreenshotPath, System.Drawing.Imaging.ImageFormat.jpeg)
ScreenshotImage = capture
- Refer 4.jpg for Output parameters of 'GetScreenshot'
- The overall 'Getscreenshot' tab looks like 5.jpg including all the required data items
3. Now, inside the process from where you want call this new Action
- Use an Action stage, choose the 'Utility - Image Manipulation', select the new Action 'GetScreenshot' from the dropdown (You need to Save and publish the VBO and hit Refresh or restart BP to reflect the new Action in the dropdown)
- Refer 6.jpg for the Input parameters of Action stage
- This is the path where the actual screenshot file will be saved. You need to make sure that the folders exists or can amend the code that checks if the folder exists and creates one if it doesn't. Note the backslash \ at the end of the path.
- Refer 7.jpg for the Output parameters of Action stage of Process call
4. The final output after running the process will look like this.
View attachment 442
i. You will find an actual image stored in the Image data item - CapturedScreenshot data item
ii. Its full file path will be in the text data item - FullSavedScreenshotPath data item
iii. A physical image will be stored in the specified folder ie; "C:\Screenshots\" in this case.
The above steps saves the actual screenshot image in an Image data item as well as saves the image to a folder path.
You can tweak the code as per your requirements perhaps something like having a flag as True or False if you want the result to be stored only in an Image data item
or only a physical image in a folder
or both.
Edit: Screenshots stored under "C:\Screenshots\"
View attachment 805
Also, the code is written such that the image is saved with the current date and time by default. If you want to customise that with the details of your running process, then that can be modified by passing a parameter to the code stage and modifying the .Save code and having a file name as required.
Similarly you can amend the code to save the image in the desired format - png, bmp ....and so on.