Skip to content

Window

The Window module has functionality for dealing primarily with the main window of an application. In contrast the Windows module supports interacting with all the windows on the desktop.

Title

Get the title of the main window. Optionally supply a timeout (in ms) for the operation. When no timeout is given the WindowTextDeadlineInMs Manatee setting is used, which defaults to 2000 ms.

Example

javascript
var title = Window.title();
// or with a timeout of 2s
title = Window.title(2000);

Minimize

Minimize the main window.

Example

javascript
Window.minimize();

Is minimized

Check if the main window is minimized.

Example

javascript
if(Window.isMinimized()) {
  ... 
}

Maximize

Maximize the main window.

Example

javascript
Window.maximize();

Is maximized

Check if the main window is maximized.

Example

javascript
if(Window.isMaximized()) {
  ... 
}

Focus

Put focus on the main window.

Parameters

  • options optional object with options for focus. Supported options:
    • askForPermission whether or not the user is asked for permission if Manatee is not allowed to focus (default is true)
    • reliably makes the focus operation work more reliably at the cost of some speed (default is false)

Example

javascript
Window.focus();
// or do not ask for permission (then no focus is done if Manatee cannot focus)
Window.focus({ askForPermission: false });

Send keys

Send keyboard events (simulated typing) to a window. Supports special strings for sending special keys.

Parameters

  • keys the keys to send - this is a string
  • options optional object with options for sendkeys, supported options:
    • focus [bool] whether to focus the window prior to sending the keys (default is true)
    • askForPermission [bool] if focusing, whether the user is asked for permission (by showing a pop-up) when Manatee is not allowed to focus (default is true)
    • reliably [bool] if focusing, makes the focus operation work more reliably (default is false)
    • useHID [bool] send the keys via the HID module instead of SendKeys (default is false)
    • wait [int] if useHID, the time in ms between key strokes (default is -1, i.e. no wait)

Example

javascript
Window.sendKeys("foo bar");
// or to send the keys without focusing the window first
Window.sendKeys("foo bar", { focus: false });

Restore

Restore the main window to a previous state and location.

Example

javascript
Window.restore();

Window with modal dialog shown

Get whether or not a modal (dialog) is shown.

Example

javascript
var modalIsShown = Window.modalShown();

WARNING

Only java

Shown with title

Get whether or not a window with the given title is shown.

Example

javascript
var windowIsShown = Window.withTitleShown("My Window");

WARNING

Only java

Move

Move the main window to the given screen coordinates. The size of the window is preserved, and the position it had before the move is recorded so that moveBack can restore it.

Parameters

  • x the new x coordinate of the top-left corner of the window
  • y the new y coordinate of the top-left corner of the window

Example

javascript
Window.move(100, 100);

Move back

Move the main window back to the position it had before the last Window.move(...). Throws if the window has not been moved with Window.move(...).

Example

javascript
Window.move(100, 100);
// ... later
Window.moveBack();

Close

Close the main window. This asks the window to close, so the application may still show e.g. a “save changes?” dialog.

Example

javascript
Window.close();

Dim

Dims the window owned by the flow.

Parameters

  • level the amount of dimming, 0-255. 255 is opaque and 0 is transparent.

Example

javascript
Window.dim(100)