Question
Endsleigh
GB
Last activity: 4 Oct 2018 13:54 EDT
Download an image using Openspan / Pega Automations
Hi,
I'm making an automation that would require displaying an image in a UI, which is taken from a website. Is there a way to download an image so that I can then set the filepath for that image in my picturebox?
Thanks,
Ryan
**Updated by Moderator: Lochan. Removed user added Ask the Expert tag. Apologies for confusion, shouldn't have been an end-user option.
***Updated by moderator: Marissa to update categories***
**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
Truist Bank
US
OK, here's a working script which I'm calling from my automation (see attached).
var 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,
PixelFormat.Format32bppArgb);
Graphics screenGraph = Graphics.FromImage(screenshot);
screenGraph.CopyFromScreen(xCoordinate,
yCoordinate,
0,
0,
new Size(width, height),
CopyPixelOperation.SourceCopy);
screenshot.Save(outputImagePath, ImageFormat.Png);
result = File.Exists(outputImagePath);
}
catch (Exception ex)
{
OpenSpan.Diagnostics.Diagnostic.PublishException(ex, null);
result = false;
}
return result;
~Erik
Pegasystems Inc.
US
Hi Ryan,
When using a windows form in your Robotic solution, you have the option to add a picture box to the form through the tool box. This picturebox component contains an image location property that accetps file paths and web location addresses as a means to dispaly specific images within the picture box. I have attached a screenshot to illiustrate the component and property.
However, there is another alternative to displaying and maintaing content with your Robotics solution. The alternative is Agile Desktop. Agile Desktop, provides you with the ability to inhouse and display custom images for your solution. It also provides a seameless means for agents to interact with your solution's automation through it's dashboard UI. Below is a link that goes into greater detail of how to use Agile Desktop.
https://support.openspan.com/link/portal/9147/9147/Article/482/Agile-Desktop-Implementation-Guide
Endsleigh
GB
Hi,
Sorry, I should have been clearer. The image I would be displaying is a dynamic image generated by a website - it is a pie chart that displays statistics, so it will be different every time. If I could download it and set the title of the image, I could then set my windows form to display an image from a file path, with the image name. Is there any way I can achieve this at all?
Thanks,
Ryan
Truist Bank
US
Hey Ryan, I have the same need and a team mate of mine has found a script to grab the entire desktop and save it as a PNG. Below is the essence of the script. I'm going to start playing around to see if I can get it focused on a particular window or area of a window. I'll let you know how I do getting it refined or if you can repost an updates I'd appreciate it!
Bitmap screenshot = new Bitmap(SystemInformation.VirtualScreen.Width,
SystemInformation.VirtualScreen.Height,
PixelFormat.Format32bppArgb);
Graphics screenGraph = Graphics.FromImage(screenshot);
screenGraph.CopyFromScreen(SystemInformation.VirtualScreen.X,
Hey Ryan, I have the same need and a team mate of mine has found a script to grab the entire desktop and save it as a PNG. Below is the essence of the script. I'm going to start playing around to see if I can get it focused on a particular window or area of a window. I'll let you know how I do getting it refined or if you can repost an updates I'd appreciate it!
Bitmap screenshot = new Bitmap(SystemInformation.VirtualScreen.Width,
SystemInformation.VirtualScreen.Height,
PixelFormat.Format32bppArgb);
Graphics screenGraph = Graphics.FromImage(screenshot);
screenGraph.CopyFromScreen(SystemInformation.VirtualScreen.X,
SystemInformation.VirtualScreen.Y,
0,
0,
SystemInformation.VirtualScreen.Size,
CopyPixelOperation.SourceCopy);
screenshot.Save("c:\\temp\\openspan\\Screenshot2.png", System.Drawing.Imaging.ImageFormat.Png);
~Erik
Accepted Solution
Truist Bank
US
OK, here's a working script which I'm calling from my automation (see attached).
var 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,
PixelFormat.Format32bppArgb);
Graphics screenGraph = Graphics.FromImage(screenshot);
screenGraph.CopyFromScreen(xCoordinate,
yCoordinate,
0,
0,
new Size(width, height),
CopyPixelOperation.SourceCopy);
screenshot.Save(outputImagePath, ImageFormat.Png);
result = File.Exists(outputImagePath);
}
catch (Exception ex)
{
OpenSpan.Diagnostics.Diagnostic.PublishException(ex, null);
result = false;
}
return result;
~Erik
Truist Bank
US
Finally here's an automation that lauches a WinForms app and takes a screen shot of it based on it's own location and size attributes.
~Erik
Endsleigh
GB
Thankyou very much for your solution Erik, it's now working perfectly for me!
There were 2 minor tweaks I had to make for it to work however, which I'll share here just in case others have the same issue:
Bitmap screenshot = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
screenshot.Save(outputImagePath, System.Drawing.Imaging.ImageFormat.Png);
Truist Bank
US
You're welcome Ryan, I'm glad to hear it worked for you!
~E
TCS
IN
Hi Ryan,
Can you please list the steps for attaching the local image in word document.
Thanks,
Saranya