A complete scripting API reference for Audio Hijack

← Scripting Center

Notes About Scripting

Execution Environment

All Scripts in Audio Hijack are run on MacOS's built in JavaScript engine, the same one as used by Safari. Furthermore, all scripts are executed on the main thread, such that long loops or slow operations may block the user interface.

Audio Hijack provides two global objects, app and console, which provide services as documented in the API reference. As well, scripts executing in response to Session Events, have a third globally accessible event object that provides context-specific information.

Executing External Programs

Audio Hijack provides two methods to interface with external programs, app.runShortcut() and app.runShellCommand().

Note that both of these methods will block the main thread of Audio Hijack, so take appropriate measures if invoking slow or long-running processes.

As well, be aware of properly escaping strings when using runShellCommand(), things like file names with spaces will need escaping.

API Reference

app

Properties

Methods


console

Properties

Methods

    log(message)

  • write message to the log. All messages will appear in Console.app.
  • error(message)

  • write error message to the log. All error messages will appear in Console.app.
  • dialog(message)

  • display an alert dialog, and write to log
  • clear()

  • clear the log

event

Properties

    eventType

  • string containing the type of event that occurred: fileDidEnd, sessionWillStart, sessionDidStop, sessionDidIdle, timerWillStart, timerDidStop, loadToCheckErrors, runScriptShortcut, runScriptTextShortcut, runNow
  • session

  • for session events, contains the session object
  • file

  • for fileDidEnd event, contains file object

Methods


session

Properties

    name

  • session name, settable
  • blocks

  • array of all blocks
  • recordings

  • array of recordings made by this session
  • running

  • session running boolean, settable
  • runTime

  • session running time, in seconds
  • windowShown

  • boolean, settable, show or hide the session's window

Methods


file

Properties

Methods


block

Properties

    name

  • name of block, settable
  • type

  • string indicating the type of the block
  • disabled

  • boolean, settable, enable or disable block

Methods


recorder

Properties

    fileName

  • file name, can include %tokens. settable
  • folderPath

  • path to recording folder, settable
  • fileTime

  • duration of current recording

Methods


switch

Properties

Methods