# Func

The **Func** object is passed to a script when it is invoked via a command. In a [script function](https://chaoses-ib.gitbook.io/directory-opus/manual/scripting/script_functions), it is passed to the [**OnClick**](https://chaoses-ib.gitbook.io/directory-opus/manual/reference/scripting_reference/scripting_events/onclick) method as the [**ClickData**](https://chaoses-ib.gitbook.io/directory-opus/manual/reference/scripting_reference/scripting_objects/clickdata)**.func** property, and in a script add-in that [adds an internal command](https://chaoses-ib.gitbook.io/directory-opus/manual/scripting/example_scripts/adding_a_new_internal_command), via the [**ScriptCommandData**](https://chaoses-ib.gitbook.io/directory-opus/manual/reference/scripting_reference/scripting_objects/scriptcommanddata)**.func** property. The **Func** object provides information about the default source and destination of the command, as well as details about how it was invoked.

| Property Name | Return Type                                                                                                                         | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| args          | *object:*[**Args**](https://chaoses-ib.gitbook.io/directory-opus/manual/reference/scripting_reference/scripting_objects/args)       | <p>Returns an <a href="args"><strong>Args</strong></a> object that provides access to any arguments given on the command line that invoked this script. This is used when the script has added an <a href="../../../scripting/example_scripts/adding_a_new_internal_command">internal command</a> to Opus. A command line template can be provided when the command is added, and any arguments the user provides on the command line for the script command will be available via this object.<br>For most use the <strong>argsmap</strong> property may be an easier way to access your command's arguments.</p>         |
| argsmap       | *object:*[**Map**](https://chaoses-ib.gitbook.io/directory-opus/manual/reference/scripting_reference/scripting_objects/map)         | Returns a [**Map**](https://chaoses-ib.gitbook.io/directory-opus/manual/reference/scripting_reference/scripting_objects/map) object that provides keyword lookup for each of the arguments given on the command line. An argument will only be present in the [**Map**](https://chaoses-ib.gitbook.io/directory-opus/manual/reference/scripting_reference/scripting_objects/map) if it was used on the command line, so you can easily check which arguments are present using the [**Map**](https://chaoses-ib.gitbook.io/directory-opus/manual/reference/scripting_reference/scripting_objects/map)**.exists()** method. |
| command       | *object:*[**Command**](https://chaoses-ib.gitbook.io/directory-opus/manual/reference/scripting_reference/scripting_objects/command) | This property returns a pre-filled [**Command**](https://chaoses-ib.gitbook.io/directory-opus/manual/reference/scripting_reference/scripting_objects/command) object that can be used to run commands against the source and destination tabs. Using this object is the equivalent of calling [**DOpusFactory**](https://chaoses-ib.gitbook.io/directory-opus/manual/reference/scripting_reference/scripting_objects/dopusfactory)**.Command** and setting the source and destination tabs manually.                                                                                                                       |
| desttab       | *object:*[**Tab**](https://chaoses-ib.gitbook.io/directory-opus/manual/reference/scripting_reference/scripting_objects/tab)         | This object represents the default destination tab for the function.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| fromdrop      | *bool*                                                                                                                              | Returns **True** if the command was invoked via a drag-and-drop operation.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| fromkey       | *bool*                                                                                                                              | Returns **True** if the command was invoked via the keyboard (i.e. via a hotkey rather than a button).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| qualifiers    | *string*                                                                                                                            | <p>Returns a string indicating any qualifier keys that were held down by the user when the command was invoked.</p><p>The string can contain any or all of the following: <em>shift,</em> <em>ctrl</em>, <em>alt</em>, <em>lwin</em>, <em>rwin</em>.</p><p>If no qualifiers were down, the string will be: <em>none</em></p>                                                                                                                                                                                                                                                                                               |
| sourcetab     | *object:*[**Tab**](https://chaoses-ib.gitbook.io/directory-opus/manual/reference/scripting_reference/scripting_objects/tab)         | This object represents the default source tab for the function.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| viewer        | *object:*[**Viewer**](https://chaoses-ib.gitbook.io/directory-opus/manual/reference/scripting_reference/scripting_objects/viewer)   | If this button was run from the [standalone image viewer](https://chaoses-ib.gitbook.io/directory-opus/manual/additional_functionality/viewing_images), this object represents the viewer window.                                                                                                                                                                                                                                                                                                                                                                                                                          |

| Method Name | **Arguments** | Return Type                                                                                                                       | Description                                                                                                                                                                                                                                                                      |
| ----------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Dlg         | *none*        | *object:*[**Dialog**](https://chaoses-ib.gitbook.io/directory-opus/manual/reference/scripting_reference/scripting_objects/dialog) | Creates a new [**Dialog**](https://chaoses-ib.gitbook.io/directory-opus/manual/reference/scripting_reference/scripting_objects/dialog) object, that lets you display dialogs and popup menus. The dialog's **window** property will be automatically assigned to the source tab. |


---

# 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://chaoses-ib.gitbook.io/directory-opus/manual/reference/scripting_reference/scripting_objects/func.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.
