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.

UPDATE: With Ranorex 2.2.0 two new actions were introduced for the Form adapter that facilitate resizing and moving forms. The Form.Resize and Form.Move methods provide a common way to achieve what the below code snippet does, regardless of the technology a form is implemented in.

int x=0;
int y=0;

// Find 'Notepad' application using RanoreXPath
Ranorex.Form form = "/form[@title='Untitled - Notepad']";
x = form.ScreenRectangle.Width - 2;
y = form.ScreenRectangle.Height - 2;

Mouse.MoveTo(form,new Location(x,y));

// Check if the application window allows it
// resize the form using the ‘CursorName’ property
if (Mouse.CursorName.Equals("SizeNWSE"))

You might also like these articles