User Tools

Site Tools


en:code:core:window

Window

Window management object than can be used to represent a window on the desktop.

Functions

Window

Constructor function.

Syntax

var myObject = new Window();
var myObject = new Window(otherWindow);

Arguments

  1. otherWindow - (Window) other Window to copy

Exceptions

  • (ParameterTypeError) incorrect parameter type
  • (ParameterCountError) incorrect parameter count

Example

Create an invalid Window.

var myObject = new Window();

Create a Window representing a copy of otherWindow.

var myObject = new Window(otherWindow);

all

Returns an array of Window representing all the windows on the desktop.

Syntax

Window.all();

Returns

  • (array) an array of Window

Example

This example will print all the windows titles in the console.

var windows = Window.all();
for(var i = 0; i < windows.length; ++i)
    Console.print(windows[i].title() + "\n");

find

Searches for windows matching some criteria. Any omitted criteria is not used. Only windows matching all criteria are returned.

Syntax

Window.find(parameters);

Arguments

  1. parameters - (object) search parameters
    • title - (string) window title
    • titleMode - (enum) see match modes for the list of possible values
    • titleCaseSensitive - (bool) set this to true if you want the title matching to be case sensitive
    • className - (string) window class name
    • classNameMode - (enum) see match modes for the list of possible values
    • classNameCaseSensitive - (bool) set this to true if you want the class name matching to be case sensitive
    • processId - (integer) set this to a process id to get only windows owned by this process
    • process - (ProcessHandle) set this to an instance of a ProcessHandle id to get only windows owned by this process

Returns

  • (array) an array of found Window

Exceptions

  • (ProcessHandleError) invalid ProcessHandle

Example

Find the window called "Notepad".

var windows = Window.find({
	title: "Notepad"
});

Find the windows whose title starts with "Notepad", using wildcards.

var windows = Window.find({
	title: "Notepad*",
	titleMode: Window.Wildcard
});

You can use the following code to show the title of all found windows :

for(var i = 0; i < windows.length; ++i)
	Console.print(windows[i].title() + "\n");

Methods

clone

Returns a copy of this Window.

Syntax

myObject.clone();

Returns

  • (Window) a copy of this Window

Example

var copyOfMyObject = myObject.clone();

equals

Returns true if this Window and another are referencing the same window.

Syntax

myObject.equals(other);

Arguments

  1. other - (Window) another Window

Returns

  • (bool) true if other is referencing the same window

Example

if(myFirstObject.equals(mySecondObject))
	//Do something

toString

Returns a string representing this Window.

Syntax

myObject.toString();

Returns

  • (string) a string representing this Window

Example

Console.print(myObject.toString());

Notes

This method is automatically called when trying to convert a Window to a string.

isValid

Returns true if this Window is referencing a window, false otherwise.

Syntax

myObject.isValid();

Returns

  • (bool) true if this Window is referencing a window

Example

if(myObject.isValid())
	//Do something

title

Returns the title of the current window.

Syntax

myObject.title();

Returns

  • (string) the title of the referenced window

Exceptions

  • (InvalidWindowError) invalid Window

Example

Console.print(myObject.title());

className

Returns the class name of the current window.

Syntax

myObject.className();

Returns

  • (string) the class name of the referenced window

Exceptions

  • (InvalidWindowError) invalid Window

Example

Console.print(myObject.className());

isActive

Returns true if this Window is the foreground Window, false otherwise.

Syntax

myObject.isActive();

Returns

  • (bool) true if this Window is the foreground Window

Exceptions

  • (InvalidWindowError) invalid Window

rect

Returns a Rect representing the rectangle of the window.

Syntax

myObject.rect();
myObject.rect(useBorders);

Arguments

- useBorders - (bool) use window borders when resizing the window (default: true) [Added in Actionaz 3.2.0.]

Returns

  • (Rect) a Rect representing the rectangle of the window

Exceptions

  • (InvalidWindowError) invalid Window

process

Returns a ProcessHandle representing the process owning the window.

Syntax

myObject.process();

Returns

  • (ProcessHandle) a ProcessHandle representing the process owning the window

Exceptions

  • (InvalidWindowError) invalid Window

close

Close this window.

Syntax

myObject.close();

Returns

  • (Window) this Window

Exceptions

  • (InvalidWindowError) invalid Window
  • (CloseWindowError) unable to close the window

killCreator

Kill the process owning this window.

Syntax

myObject.killCreator();

Returns

  • (Window) this Window

Exceptions

  • (InvalidWindowError) invalid Window
  • (KillCreatorError) unable to kill the the window owner

setForeground

Set this window to the foreground.

Syntax

myObject.setForeground();

Returns

  • (Window) this Window

Exceptions

  • (InvalidWindowError) invalid Window
  • (SetForegroundError) unable to set this window to the foreground

minimize

Minimize the window.

Syntax

myObject.minimize();

Returns

  • (Window) this Window

Exceptions

  • (InvalidWindowError) invalid Window
  • (MinimizeError) unable to minimize the window

maximize

Maximize the window.

Syntax

myObject.maximize();

Returns

  • (Window) this Window

Exceptions

  • (InvalidWindowError) invalid Window
  • (MaximizeError) unable to maximize the window

move

Move the window.

Syntax

myObject.move(point);

Arguments

  1. point - (Point) point where to move the window

Returns

  • (Window) this Window

Exceptions

  • (InvalidWindowError) invalid Window
  • (MoveError) unable to move the window

resize

Resize the window.

Syntax

myObject.resize(size);
myObject.resize(size, useBorders);

Arguments

  1. size - (Size) the new size of the window
  2. useBorders - (bool) use window borders when resizing the window (default: true) [Added in Actionaz 3.2.0.]

Returns

  • (Window) this Window

Exceptions

  • (InvalidWindowError) invalid Window
  • (ResizeError) unable to resize the window

Enumerations

Match mode

Match modes for the find function.

Values

  1. RegExp: search using regular expressions
  2. Wildcard: search using wildcards
  3. WildcardUnix: search using Unix type wildcards
  4. FixedString: search using a fixed string

Example

Find the windows whose title starts with "Notepad", using wildcards.

var windows = Window.find({
	title: "Notepad*",
	titleMode: Window.Wildcard
});
en/code/core/window.txt · Last modified: 2021/02/13 11:23 by 127.0.0.1