# Using scripts to automate tasks

Scripts in Fotografix are a sequence of commands that can be used to automate frequent tasks. Almost all commands available through menus can be executed automatically by using a script.

## Running a script

The scripts palette on the right hand side of the Fotografix window lists all available scripts. To run a script, simply double-click its name. Some scripts may work on a selected region of an image. (usually indicated in the name) In such cases, first select a region of the image before running the script.

## Creating custom scripts

A Fotografix script is simply a text file containing a sequence of commands to be executed, one per line. Lines starting with a ; (semicolon) are treated as comments. To use a script in Fotografix, save your script with a .fgs extension inside the Scripts folder. For a list of all supported commands, see Scripting commands.

## Script parameters

Any script command that takes a number as a parameter can optionally be suffixed with one of the following letters to multiply it with that value.

Suffix | Description
--- | ---
w | Width of the active layer
h | Height of the active layer
W | Width of the image
H | Height of the image

For example, the parameter `0.1W` will evaluate to 10% of the image width.

## Sample script - sepia tone

The following is a sample script (provided along with Fotografix as Default Scripts\Sepia Tone.fgs) that gives a sepia tone to the image:

    Desaturate
    ColourBalance 100 25 0

The above script works by first converting the image to grayscale and then adjusting the colour balance to impart a sepia tone. Due to the nature of the commands used in the script, it works both with and without a selection.