> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Using scripts in ABBYY Scanning Station

> Automate ABBYY Scanning Station with custom scripts in JScript, VBScript, or .Net languages, covering collections, registry options, and global modules.

Custom scripts enable you to create your own scenarios of working with ABBYY Scanning Station. Typical scenarios include:

* Placing scanned pages in the correct order after duplex scanning
* Auto-split of large-size pages after scanning
* Automatic filling in registration parameters for newly created batches and documents
* Quality check of pages with an external component
* Saving pages to two export targets simultaneously, one of which can be used for backup

Scripts can be launched both automatically (in response to certain events) and by an explicit user command.

## Supported scripting languages

The following scripting languages are supported: **JScript®**, **VBScript**, **C#.Net**, **VisualBasic.Net** or **JScript.Net**.

## Specifics of usage

In VBScript, you must use the keyword `Me` when referring to the methods and fields of the current object (the alternative of `this` in JScript, `Workspace` in VisualBasic.Net). In export scripts, the keyword `Me` (VBScript), `this` (JScript, C#.Net) or `Workspace` (VisualBasic.Net) implements the [IExportBatch](/flexi-capture/scanning-station/shared/scripts/export-batch) interface. In the event scripts, the keyword `Me`, `this` or `Workspace` implements the [IWorkSpace](/flexi-capture/scanning-station/shared/scripts/workspace) interface.

<h2 id="collections">
  Working with collections
</h2>

All collections support the following properties and methods:

| **Name**            | **Type**      | **Access** | **Description**                                                                    |
| ------------------- | ------------- | ---------- | ---------------------------------------------------------------------------------- |
| Count               | int           | Read-only  | The number of items in the collection                                              |
| Item( index : int ) | ItemInterface | Read-only  | Retrieves the collection item at the specified index. Enumeration begins with "0". |

Instead of using the method *Item* you can also address items of the collection using parentheses.

For example:

```
Items( 1 ).Text = "Hello"
```

If C#.Net is used, the index is specified in brackets:

```
Items[1].Text = "Hello"
```

All collections can be used in *"for each"* and similar constructs.

## Registry key options

For scripts launched on the ABBYY Scan Station you can change the following values in the registry:

`HKEY_CURRENT_USER\Software\ABBYY\ScanStationFC\4.0\Shell\Script\DisableDebugging`

`HKEY_CURRENT_USER\Software\ABBYY\ScanStationFC\4.0\Shell\Script\DisableEventScripts`

By default, both values are set to **false**.

Changing the value of **DisableEventScripts** to **true** prevents new scripts from launching. Already running scripts are not disabled by this command.

## Custom functions

In the script editor, users can create their own functions and procedures and then call them from event scripts and sending scripts.

Custom functions can be created in one of the global modules – either in the global module of events or in the global module of export. To add a custom function, click the arrow next to the script name in the [Script Editor](/flexi-capture/scanning-station/shared/interface/script-editor) and select GlobalModule.

All functions within one module must be written in the same language. The core code of a sending script or an event handler can be written in a language different from that used in the corresponding global module.

For example, from the event script written in VBScript you can call a function contained in the global module that is written in JScript.

Functions can only be called from "their own" modules. This means that from event scripts you can only call functions contained in the global event module, and from the code of sending scripts you can only call functions contained in the global export module. Otherwise, you will get an error during execution.
