Skip to content
snarfed edited this page Feb 26, 2013 · 5 revisions

The Window Object is returned by various Slate API functions. This page describes it in detail.

Description

The Window Object represents a currently open window.

Functions

title

Return the Title of the Window.

// assuming win is the Window Object
var title = win.title();

topLeft

Alias: tl

Return the top left point that represents this Window's location.

// assuming win is the Window Object
var topLeft = win.topLeft();
var topLeftX = topLeft.x;
var topLeftY = topLeft.y;

size

Return the size of this Window.

// assuming win is the Window Object
var size = win.size();
var width = size.width;
var height = size.height;

rect

Return the rectangle that represents this Window's location and size.

// assuming win is the Window Object
var rect = win.rect();
var topLeftX = rect.x;
var topLeftY = rect.y;
var width = rect.width;
var height = rect.height;

pid

Return the Process Identifier of the Window.

// assuming win is the Window Object
var pid = win.pid();

focus

Focus the Window. Returns true if the focus succeeded, false if it did not.

// assuming win is the Window Object
var success = win.focus();

isMinimizedOrHidden

Alias: hidden

Returns true if the Window is minimized or hidden, false if not.

// assuming win is the Window Object
var isMinimizedOrHidden = win.isMinimizedOrHidden();

isMain

Alias: main

Returns true if the Window is the main window of its Application, false if not.

// assuming win is the Window Object
var isMain = win.isMain();

move

Move the window to a new location. You may use Expressions which will be evaluated based on the screen the window is on or the "screen" parameter in the parameter hash. Returns true if the move succeeded, false if it did not.

// assuming win is the Window Object
var success = win.move({
  "x" : "screenOriginX",
  "y" : "screenOriginY",
  "screen" : "0"
});

isMovable

Alias: movable

Returns true if this window can be moved, false otherwise.

// assuming win is the Window Object
var isMovable = win.isMovable();

resize

Resize the window. You may use Expressions which will be evaluated based on the screen the window is on or the "screen" parameter in the parameter hash. Returns true if the resize succeeded, false if it did not.

// assuming win is the Window Object
var success = win.resize({
  "width" : "screenSizeX",
  "height" : 500
});

isResizable

Alias: resizable

Returns true if this window can be resized, false otherwise.

// assuming win is the Window Object
var isResizable = win.isResizable();

doOperation

Alias: doop

Perform any operation on the window. Returns true if the operation succeeded, false if it did not.

var push = slate.operation("push", { "direction" : "up" });
var success = win.doOperation(push);

OR

var success = win.doOperation("push", { "direction" : "up" });

screen

Return the screen object representing the screen this window is on.

var screen = win.screen();

app

Return the application object representing the application of this window.

var app = win.app();