The scriptContext Object

Detecting When a Script is Run as an Autoscript

Using the scriptContext object, you can detect when a script is being run as an autoscript. This allows you to code a script so that it functions in either context (autoscript or not). This trivial script illustrates the approach.

Sub Main
    If scriptContext Is Nothing Then
     MsgBox "I'm not an autoscript"
    Else
     MsgBox "I'm an autoscript"
    End If
End Sub

Getting Values Required by Autoscripts

The scriptContext object provides access to values required by an autoscript, such as the output item that triggered the current autoscript.

Note: The object returned by scriptContext.GetOutputItem is not activated. If your script requires an activated object, you'll need to activate it--for instance, with the ActivateTable method. When you're finished with any manipulations, call the Deactivate method.