Question
Cognizant
AU
Last activity: 6 Nov 2018 20:02 EST
taking a screenshot
Hi,
I am trying to take a screenshot of Excel Application using Pega Robotic Automation(8.0) but couldn't find any solution to do that.
Thanks
**Moderation Team has archived post**
This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Pegasystems Inc.
US
Once you have added the method to the script container, you can then click on the script container in the Object Explorer window and see your new method on the Methods section. This method takes in 4 parameters;
string outputImagePath (the full path and file name to where you want to save the file), int width (the width you'd like the screenshot to be), int height (the height you want the screenshot to be), int xCoordinate (the x coordinate where you want to start the rectangle), int yCoordinate (the y coordinate where you want to start the rectangle).
Accenture Solutions Pvt Ltd
IN
which type of screenshot you are trying to make ?you cant interrogate Excel application in openspan.
Regards,
Pravallika.
Cognizant
AU
I have an excel application, i want to take a screenshot of it and paste it in a word doc.
Endsleigh
GB
You can use the Script tool and input the following:
Name: GrabScreenShotPNG
Parameters: string outputImagePath, int width, int height, int xCoordinate, int yCoordinate
Result type: bool
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;
-
Darija Sokolova
GE
IN
I am trying to take screenshot of the Pega web application. Can you please tell me how to use the above given code script and take a screenshot ? Also there is something called GetScreenshot method, if someone can tell me how to use that will also be great.
#helpme
Pegasystems Inc.
US
You add this code to the Script component available on the Advanced tab in the toolbox. The part in Ryan's reply below the bold Result Type bool goes into the main area. The sections above are filled in to their corresponding labels as shown in my screenshot.
GE
IN
Thanks for the reply. Yes I did add the script to my automation. Now I want to know how to use it or how to call this script in my automation. Also the parameters how to pass. ??
Accepted Solution
Pegasystems Inc.
US
Once you have added the method to the script container, you can then click on the script container in the Object Explorer window and see your new method on the Methods section. This method takes in 4 parameters;
string outputImagePath (the full path and file name to where you want to save the file), int width (the width you'd like the screenshot to be), int height (the height you want the screenshot to be), int xCoordinate (the x coordinate where you want to start the rectangle), int yCoordinate (the y coordinate where you want to start the rectangle).
GE
IN
Thanks that was really helpful. While i was giving the path, i did not mention the file name C:/storescreenshot. That was making it false all the time.
General Electric
IN
Hi,
I tried with the same steps provided above,can you please help me with debugging as it always goes to false.
Thanks in advance
Shruthi
Pegasystems Inc.
US
What parameters are you supplying to the method?
General Electric
IN
Pegasystems Inc.
US
What is the outputImagePath value? Are you able to write to this location?
General Electric
IN
yes i have access and it is a writable place,problem is i am unable to debug it.
The automation goes to false there are multiple places where it can go to false,how to i check where the false is being set ? or how to debug the flow of code ?
-
Harish Barodiya
Pegasystems Inc.
US
You are on the right path by adding log messages into the script. That is the only way to debug a script. Make sure your outputImagePath is a full file name (something like C:\temp\image.png). If you have access to Visual Studio, you can execute the code within Visual Studio and use their debugger to go through it, but usually adding log messages for something as simple as this is the way to go. If the logs are too intimidating, you can also add message boxes (call the static method "MessageBox.Show("some message"); "). This can also be used to help you determine where it is failing.
Anthem
US
Please let us know how to add the screenshot to the wordpad.
And please let us know how to take the active webpage screenshot or tell us how to find width and height of the webpage
Pegasystems Inc.
US
Please start a new thread about this as these are new questions.
Anthem
US
As it is a part of above question, I asked it in this thread. I think we need to few modification in the above method to get active window screenshot. could you pls inform me?
HCL
MY
Hi Sasnt,
I am trying to take screenshot and paste at desire location but my code is not working,Can you please review the attached code and let me know where i am wrong.It will be very much helpful for me ,
Mphasis
IN
Please set up breakpoints and see where exactly your automation is failing. Also, from the script block, connect separately from the True and False points and see where the flow is going
Mphasis
IN
I am trying the same code and it always returns a true result. The file also gets created, but it is blank. I have tried with various combinations for the coordinates and the dimensions but there is no image.
I am just trying to go to google, enter test as the string and hit enter. In the search results page I am taking the screen-shot. Attached is the Google automation and the blank image that is getting created
Pegasystems Inc.
US
It looks like you are giving coordinates where on the screen, Google is blank. Try loading a more dynamic webpage where there are no blank areas. I suspect you are just providing the wrong coordinates.
Mphasis
IN
Yes...I got that corrected and am able to save the image to the desktop. But I am not able to embed the image directly in the body of the outlook email. I do have a separate post for that https://collaborate.pega.com/discussion/shutting-down-pvs
Perficient Inc - New York
US
Is there a way I could save the screenshot as a pdf instead of a png?