Resizing windows and dialogs with Ranorex
In cases of .NET forms it’s possible to set the size value of an application form directly using the Ranorex invoke mechanism. But if you’d like to change the size of forms which are not of type .NET WinForms you need to simulate mouse move actions to point it exactly to the lower right corner. The following short code snippet describes how to resize all kind of windows by simulating mouse actions with Ranorex.
int x=0;
int y=0;
// Find 'Notepad' application using RanoreXPath
Ranorex.Form form = "/form[@title='Untitled - Notepad']";
form.Activate();
x = form.ScreenRectangle.Width - 2;
y = form.ScreenRectangle.Height - 2;
Report.Log(ReportLevel.Info,"",Mouse.CursorName);
Mouse.MoveTo(form,new Location(x,y));
Report.Log(ReportLevel.Info,"",Mouse.CursorName);
// Check if the application window allows it
// resize the form using the ‘CursorName’ property
if (Mouse.CursorName.Equals("SizeNWSE"))
{
Mouse.ButtonDown(MouseButtons.Left);
Mouse.MoveTo(form.ScreenRectangle.Right+30,form.ScreenRectangle.Bottom+30);
Mouse.ButtonUp(MouseButtons.Left);
}
Subscribe