Question
Mphasis
IN
Last activity: 14 Aug 2017 10:13 EDT
Taking screenshot in RPA
We have a requirement to open up a URL in a browser, use the snipping tool and take a screen capture of the footer (assuming the coordinates are fixed), and then paste this to the mail.
Please let us know how this can be achieved.
***Edited by Moderator Marissa to update categories***
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Mphasis
IN
Yes...it is working. Please find attached the screen-shot of the automation. The automation, just goes to google, enters a search term, searches and then takes a screen-shot of the resulting page.
Here are the two functions referred:
Function: GrabScreenShotPNG
Parameters: string outputImagePath, int width, int height, int xCoordinate, int yCoordinate
Result type: bool
Code
//////////////////////////////
bool result = false;
if (string.IsNullOrEmpty(outputImagePath))
{
return false;
}
OpenSpan.Diagnostics.Diagnostic.TraceVerbose("Script", string.Format("Attempting to grab screen shot {0}/{1}/{2}/{3}", width, height, xCoordinate, yCoordinate));
try
{
Bitmap screenshot = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics screenGraph = Graphics.FromImage(screenshot);
screenGraph.CopyFromScreen(xCoordinate, yCoordinate, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy);
screenshot.Save(outputImagePath, System.Drawing.Imaging.ImageFormat.Png);
result = File.Exists(outputImagePath);
}
catch (Exception ex)
{
OpenSpan.Diagnostics.Diagnostic.PublishException(ex, null);
result = false;
Yes...it is working. Please find attached the screen-shot of the automation. The automation, just goes to google, enters a search term, searches and then takes a screen-shot of the resulting page.
Here are the two functions referred:
Function: GrabScreenShotPNG
Parameters: string outputImagePath, int width, int height, int xCoordinate, int yCoordinate
Result type: bool
Code
//////////////////////////////
bool result = false;
if (string.IsNullOrEmpty(outputImagePath))
{
return false;
}
OpenSpan.Diagnostics.Diagnostic.TraceVerbose("Script", string.Format("Attempting to grab screen shot {0}/{1}/{2}/{3}", width, height, xCoordinate, yCoordinate));
try
{
Bitmap screenshot = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics screenGraph = Graphics.FromImage(screenshot);
screenGraph.CopyFromScreen(xCoordinate, yCoordinate, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy);
screenshot.Save(outputImagePath, System.Drawing.Imaging.ImageFormat.Png);
result = File.Exists(outputImagePath);
}
catch (Exception ex)
{
OpenSpan.Diagnostics.Diagnostic.PublishException(ex, null);
result = false;
}
return result;
/////////////////////////////
Function: SendEmail
Parameters: string str1
Result type: int
Code
////////////////
////////////////////
Mphasis
IN
I have tried the solution given in https://pdn.pega.com/community/product-support/question/taking-screenshot.
But facing two issues:
1) The image file that is created is always blank
2) I do not want to save to a file, rather want this to be pasted to the outlook mail body
Please let me know how this can be achieved
Mphasis
IN
I am able to get the image file with the screen-capture now, the issue was with the coordinates. But still not sure how to copy the image to the clipboard and paste it to a mail. Please help with this.
Virtusa Consulting UK
GB
Please check the post.
Mphasis
IN
Yes...I tried that and am able to create the image file to the desktop. But I am unable to embed the image in the body of the outlook mail, and need help with that
Mphasis Unleash the Next
IN
Hi,
Did you find a way to embed the image in the body of the outlook mail..........i am working on it now, if you got the solution please help me with the same. Thanks
Accepted Solution
Mphasis
IN
Yes...it is working. Please find attached the screen-shot of the automation. The automation, just goes to google, enters a search term, searches and then takes a screen-shot of the resulting page.
Here are the two functions referred:
Function: GrabScreenShotPNG
Parameters: string outputImagePath, int width, int height, int xCoordinate, int yCoordinate
Result type: bool
Code
//////////////////////////////
bool result = false;
if (string.IsNullOrEmpty(outputImagePath))
{
return false;
}
OpenSpan.Diagnostics.Diagnostic.TraceVerbose("Script", string.Format("Attempting to grab screen shot {0}/{1}/{2}/{3}", width, height, xCoordinate, yCoordinate));
try
{
Bitmap screenshot = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics screenGraph = Graphics.FromImage(screenshot);
screenGraph.CopyFromScreen(xCoordinate, yCoordinate, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy);
screenshot.Save(outputImagePath, System.Drawing.Imaging.ImageFormat.Png);
result = File.Exists(outputImagePath);
}
catch (Exception ex)
{
OpenSpan.Diagnostics.Diagnostic.PublishException(ex, null);
result = false;
Yes...it is working. Please find attached the screen-shot of the automation. The automation, just goes to google, enters a search term, searches and then takes a screen-shot of the resulting page.
Here are the two functions referred:
Function: GrabScreenShotPNG
Parameters: string outputImagePath, int width, int height, int xCoordinate, int yCoordinate
Result type: bool
Code
//////////////////////////////
bool result = false;
if (string.IsNullOrEmpty(outputImagePath))
{
return false;
}
OpenSpan.Diagnostics.Diagnostic.TraceVerbose("Script", string.Format("Attempting to grab screen shot {0}/{1}/{2}/{3}", width, height, xCoordinate, yCoordinate));
try
{
Bitmap screenshot = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics screenGraph = Graphics.FromImage(screenshot);
screenGraph.CopyFromScreen(xCoordinate, yCoordinate, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy);
screenshot.Save(outputImagePath, System.Drawing.Imaging.ImageFormat.Png);
result = File.Exists(outputImagePath);
}
catch (Exception ex)
{
OpenSpan.Diagnostics.Diagnostic.PublishException(ex, null);
result = false;
}
return result;
/////////////////////////////
Function: SendEmail
Parameters: string str1
Result type: int
Code
////////////////
////////////////////
Mphasis Unleash the Next
IN
Thank's a lot.......that's very helpful........