Skip to content

Operations ​

Operations define the specific actions that scripts will execute. The same instruction structure is used in both task definitions (scripts) and UI extensions (views).

Instruction Structure ​

All operations contain two required fields:

json
{
  "command": {
    "action": "operation_type",
    "args": ["param1", "param2", ...]
  }
}
FieldTypeRequiredDescription
actionstring✅Operation type
argsarray✅Operation arguments array

Supported Operation Types ​

iClick supports 5 operation types:

OperationPurposeUse Cases
$.nodejs.runExecute Node.js scriptsRun NODE scripts
$.shell.openExecute external programsLaunch exe, open files
$.http.getHTTP GET requestCall APIs
$.http.postHTTP POST requestCall APIs
$.webview.openOpen WebView windowDisplay web management interface

$.nodejs.run ​

Execute Node.js script files.

Syntax ​

json
{
  "action": "$.nodejs.run",
  "args": ["script_path", "param1", "param2", ...]
}

Parameters ​

ParameterTypeRequiredDescription
args[0]string✅Node.js script path
args[1+]stringOptionalScript parameters

Path Rules ​

  • Relative path: Relative to script package directory

    json
    "args": ["script.js", "arg1"]
    // Actual path: %APPDATA%/iClick/Scripts/ScriptID/script.js
  • Absolute path: Full file path

    json
    "args": ["C:\\Users\\Admin\\scripts\\task.js", "arg1"]

$.shell.open ​

Execute external programs or open files.

Syntax ​

json
{
  "action": "$.shell.open",
  "args": ["program_path", "param1", "param2", ...]
}

Parameters ​

ParameterTypeRequiredDescription
args[0]string✅Program path
args[1+]stringOptionalCommand line arguments

Path Rules ​

  • Relative path: Relative to script package directory

    json
    "args": ["Tool.exe", "arg1"]
    // Actual path: %APPDATA%/iClick/Scripts/ScriptID/Tool.exe
  • Absolute path: Full file path

    json
    "args": ["C:\\Program Files\\MyApp\\app.exe", "arg1"]

$.http.get ​

Send HTTP GET request.

Syntax ​

json
{
  "action": "$.http.get",
  "args": ["URL", {query_params}, {headers}]
}

Parameters ​

ParameterTypeRequiredDescription
args[0]string✅Request URL
args[1]objectOptionalQuery parameters object
args[2]objectOptionalRequest headers object

$.http.post ​

Send HTTP POST request.

Syntax ​

json
{
  "action": "$.http.post",
  "args": ["URL", {request_body}, {headers}]
}

Parameters ​

ParameterTypeRequiredDescription
args[0]string✅Request URL
args[1]objectOptionalRequest body object
args[2]objectOptionalRequest headers object

$.webview.open ​

Open embedded WebView window.

Syntax ​

json
{
  "action": "$.webview.open",
  "args": ["URL", {window_options}]
}

Parameters ​

ParameterTypeRequiredDescription
args[0]string✅URL address
args[1]objectOptionalWindow options object

Window Options ​

OptionTypeDefaultDescription
widthnumber800Window width (pixels)
heightnumber600Window height (pixels)
alwaysOnTopbooleanfalseAlways on top
resizablebooleantrueResizable
maximizablebooleantrueMaximizable
minimizablebooleantrueMinimizable
maxWidthnumber-Maximum width
maxHeightnumber-Maximum height

Magic Variables ​

You can use magic variables in operation parameters (e.g., in context menus), which will be automatically replaced with actual values at runtime.

Available Variables ​

VariableDescriptionExample Value
$.deviceIdCurrently selected device ID"iPhone-12345"

Use Cases ​

Magic variables are particularly useful for scenarios that require current context information:

Cooperation: try.catch@foxmail.com