# Scripting

OffShoot is built with extensibility in mind. Trigger your custom scripts on specific events, and run custom processes, other apps, or integrate OffShoot into an existing workflow.

{% hint style="info" %}
This feature requires an OffShoot Pro license.
{% endhint %}

<figure><img src="/files/ynMco2voFfmeDRiyvxbe" alt=""><figcaption></figcaption></figure>

## Getting started

{% hint style="danger" %}
Scripting is a powerful tool. Easy to learn, but even easier to screw up. Always test your script with disposable data, and then test again. And again. Hedge does not offer support or assume responsibility for problems with or due to examples or any other script. If you’re new to scripting, find someone to help you out, or use the example scripts available here. Remember: you are solely responsible.
{% endhint %}

The following events are available:

1. [OffShoot Started](/offshoot/features/automation/scripts/events/offshoot-started.md)
2. [Disk Added](/offshoot/features/automation/scripts/events/disk-added.md)
3. [Disk Removed](/offshoot/features/automation/scripts/events/disk-removed.md)
4. [Disk Busy](/offshoot/features/automation/scripts/events/disk-busy.md)
5. [Disk Idle](/offshoot/features/automation/scripts/events/disk-idle.md)
6. [Disks Idle](/offshoot/features/automation/scripts/events/disk-idle.md)
7. [Transfers Added](/offshoot/features/automation/scripts/events/transfers-added.md)
8. [File Copy Completed](/offshoot/features/automation/scripts/events/filecopycompleted.md)
9. [Verification Issue](/offshoot/features/automation/scripts/events/checkpoint-issue.md)

Each event can trigger a script (Python or AppleScript) and has its own set of unique parameters that you can use.&#x20;

## Good to know

* Timestamps are shown as `YYYYMMDDHHMMSS.`
* Duration is in seconds, with six-digit precision.
* Size is in bytes. To convert bytes to GBs, divide by 1024^3.
* Script Events are logged in OffShoot's [Event Log](/offshoot/need-help.md).

## Python

OffShoot can trigger a Python script and pass its event parameters as a JSON string argument.&#x20;

### Requirements

* macOS
  * OffShoot for Mac 25.2 and newer
  * Python 3, accessible via the `python3` command in your system PATH
* Windows
  * OffShoot for Windows 22.2.6 and newer
  * Python 3 path set in the Registry in `PyLauncher` key, located at: `HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Python\PyLauncher`

### Example Script

Use the Python example below to write OffShoot's event parameters to a file in `/tmp`&#x20;

{% file src="/files/RIS8E96P5p197LrmDZ9c" %}

{% hint style="info" %}
On Windows, when your script does not get fired, check the `hedge.log` file located in `C:\Users\<your-user-name>\AppData\Roaming\Hedge`  for clues. The most common issue is that a script launcher is not found:\
\
`ERROR Utilities.Python.PythonHelper - Required PyLauncher for running python scripts was not found in the registry at location 'HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Python\PyLauncher'`

\
Try (Re)installing Python with the official installer, and make sure to enable `Use admin privileges.`
{% endhint %}

## AppleScript

{% hint style="info" %}
AppleScript is supported on macOS only.
{% endhint %}

To be able to use a parameter, you must first declare it at the top of your script:

```
set theFolder to "{FileCopyCompleted_destinationPath}"
```

* `return theFolder` to output into the Event Log
* `display alert "theFolder = " & theFolder`
* `display notification with title "theFolder =" subtitle theFolder`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hedge.video/offshoot/features/automation/scripts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
