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
var title = Window.title();
// or with a timeout of 2s
title = Window.title(2000);Minimize
Minimize the main window.
Example
Window.minimize();Is minimized
Check if the main window is minimized.
Example
if(Window.isMinimized()) {
...
}Maximize
Maximize the main window.
Example
Window.maximize();Is maximized
Check if the main window is maximized.
Example
if(Window.isMaximized()) {
...
}Focus
Put focus on the main window.
Parameters
optionsoptional object with options for focus. Supported options:askForPermissionwhether or not the user is asked for permission if Manatee is not allowed to focus (default istrue)reliablymakes the focus operation work more reliably at the cost of some speed (default isfalse)
Example
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
keysthe keys to send - this is a stringoptionsoptional object with options for sendkeys, supported options:focus[bool] whether to focus the window prior to sending the keys (default istrue)askForPermission[bool] if focusing, whether the user is asked for permission (by showing a pop-up) when Manatee is not allowed to focus (default istrue)reliably[bool] if focusing, makes the focus operation work more reliably (default isfalse)useHID[bool] send the keys via the HID module instead ofSendKeys(default isfalse)wait[int] ifuseHID, the time in ms between key strokes (default is-1, i.e. no wait)
Example
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
Window.restore();Window with modal dialog shown
Get whether or not a modal (dialog) is shown.
Example
var modalIsShown = Window.modalShown();WARNING
Only java
Shown with title
Get whether or not a window with the given title is shown.
Example
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
xthe new x coordinate of the top-left corner of the windowythe new y coordinate of the top-left corner of the window
Example
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
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
Window.close();Dim
Dims the window owned by the flow.
Parameters
levelthe amount of dimming, 0-255. 255 is opaque and 0 is transparent.
Example
Window.dim(100)