Good Afternoon,
I have created an script with a screenshot by Ranorex.
I would like to know if there is the way to use this screenshot (where is located) and manipulate the image.
At the end I need to get the image (screenshot) and to send an email with it. Of course, to do that there will be another automation software.
Thank you for your help.
How to use the screenshot image or manipulate it
Re: How to use the screenshot image or manipulate it
Hi all,
this is the code present:
and I found it in past threads:
but I am unable to merge with my code.
Thank you for your help.
this is the code present:
Code: Select all
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Drawing;
using System.Threading;
using WinForms = System.Windows.Forms;
using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Testing;
namespace XXX
{
public partial class ScreenShot
{
/// <summary>
/// This method gets called right after the recording has been started.
/// It can be used to execute recording specific initialization code.
/// </summary>
private void Init()
{
// Your recording specific initialization code goes here.
}
public void Mouse_Click_None2()
{
Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'MozillaFi1.Grouping.None2' at 280;483.", repo.MozillaFi1.Grouping.None2Info);
repo.MozillaFi1.Grouping.None2.Click("280;483");
}
}
}
and I found it in past threads:
Code: Select all
private void ReportScreenshot()
{
string oldreportname = Ranorex.Core.Reporting.TestReport.ReportEnvironment.ReportName;
string newreportname = "SCREENSHOTNAME";
Ranorex.Core.Reporting.TestReport.ReportFilename = newreportname;
Report.Screenshot(REPOELEMENT);
Ranorex.Core.Reporting.TestReport.ReportFilename = oldreportname;
}
Code: Select all
Bitmap bmp = Imaging.CaptureImage(repo.YourElement.Self);
bmp.Save(@"C:\PathToAFolder\CustomName.jpg");
Code: Select all
private static void screenshot(){
//Screenshot Start
try{
var bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height,
PixelFormat.Format32bppArgb);
// Create a graphics object from the bitmap.
var gfxScreenshot = Graphics.FromImage(bmpScreenshot);
// Take the screenshot from the upper left corner to the right bottom corner.
gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
Screen.PrimaryScreen.Bounds.Y,
0,
0,
Screen.PrimaryScreen.Bounds.Size,
CopyPixelOperation.SourceCopy);
// Save the screenshot to the specified path that the user has chosen.
bmpScreenshot.Save("Screenshot123.png", ImageFormat.Png);
}catch(Exception e){
Report.Log(ReportLevel.Error, "Screenshot", e.Message);
}
}
Thank you for your help.
- RobinHood42
- Posts: 324
- Joined: Fri Jan 09, 2015 3:24 pm
Re: How to use the screenshot image or manipulate it
Hi Simonez,
I'm afraid that it's not clear what is meant by this:
Cheers,
Robin
I'm afraid that it's not clear what is meant by this:
Where exactly do you need help? Maybe you could also upload a small sample solution to give us a better understanding of your requirements."but I am unable to merge with my code."
Cheers,
Robin
Re: How to use the screenshot image or manipulate it
Hi Robin,
Thank you for your reply.
I want to capture the screenshot made by Ranorex (Image based) and save it on local folder.
Is there a way to do that?
Thanks
Thank you for your reply.
I want to capture the screenshot made by Ranorex (Image based) and save it on local folder.
Is there a way to do that?
Thanks
Re: How to use the screenshot image or manipulate it
I do something along these lines to take a Ranorex object and save an image to HDD:
Code: Select all
Ranorex.Unknown element = ...
Bitmap bmp = Ranorex.Imaging.CaptureDesktopImage(element);
CompressedImage actual_image = new CompressedImage(bmp, ImageFormat.Png);
actual_image.Store(filename);
- RobinHood42
- Posts: 324
- Joined: Fri Jan 09, 2015 3:24 pm
Re: How to use the screenshot image or manipulate it
Hi Simonez,
another possiblity would be:
Robin
another possiblity would be:
public void SaveScreenshot(RepoItemInfo item) { var adapter = item.CreateAdapter<Button>(false); adapter.CaptureCompressedImage().Store(@"C:\temp\image.png"); }Hope this helps,
Robin
Re: How to use the screenshot image or manipulate it
Hi all,
thank you for all the replies.
I wasn't unable to add your code and to find a solution.
@Stub: there were a lot of fields to fill in and I tried them in different way but without result.
@ RobinHood42: I put your code, as well, in ScreenShot.UserCode.cs but it complains about RepoItemInfo item.
Below you will the code of ScreenShot.UserCode.cs. The script automatically creates the method private void Init() even if I overwrite it.
Please let me know if you need more information.
thank you for all the replies.
I wasn't unable to add your code and to find a solution.
@Stub: there were a lot of fields to fill in and I tried them in different way but without result.
@ RobinHood42: I put your code, as well, in ScreenShot.UserCode.cs but it complains about RepoItemInfo item.
Below you will the code of ScreenShot.UserCode.cs. The script automatically creates the method private void Init() even if I overwrite it.
Code: Select all
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Drawing;
using System.Threading;
using System.IO;
using WinForms = System.Windows.Forms;
using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Testing;
namespace Blue
{
public partial class ScreenShot
{
/// <summary>
/// This method gets called right after the recording has been started.
/// It can be used to execute recording specific initialization code.
/// </summary>
public void SaveScreenshot(RepoItemInfo item)
{
var adapter = item.CreateAdapter<Button>(false);
adapter.CaptureCompressedImage().Store(@"C:\temp\image.png");
}
private void Init()
{
// Your recording specific initialization code goes here.
}
}
}
- RobinHood42
- Posts: 324
- Joined: Fri Jan 09, 2015 3:24 pm
Re: How to use the screenshot image or manipulate it
Hi,
Please find attached a sample recording, which simply can be added to your current Rx solution.
Cheers,
Robin
Please find attached a sample recording, which simply can be added to your current Rx solution.
Cheers,
Robin
You do not have the required permissions to view the files attached to this post.
Re: How to use the screenshot image or manipulate it
Dear RobinHood42,RobinHood42 wrote:Hi,
Please find attached a sample recording, which simply can be added to your current Rx solution.
Cheers,
Robin
First, thank you very much for your help.
I downloaded your solution. Created a new module named 'Recording1' save and close Ranorex. Copied the files: Recording1.cs and Recording1.UserCode.cs into the folder of the project.
Restarted Ranorex. It works correctly but doesn't leave no one picture.
Do I have done something wrong?
Cheers
I hope that I don't bother you.
- RobinHood42
- Posts: 324
- Joined: Fri Jan 09, 2015 3:24 pm
Re: How to use the screenshot image or manipulate it
Hi,
Well, did you check if the user code method is actually called?
Cheers,
Robin
Well, did you check if the user code method is actually called?
Cheers,
Robin