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:
{
"command": {
"action": "operation_type",
"args": ["param1", "param2", ...]
}
}| Field | Type | Required | Description |
|---|---|---|---|
action | string | ✅ | Operation type |
args | array | ✅ | Operation arguments array |
Supported Operation Types
iClick supports 5 operation types:
| Operation | Purpose | Use Cases |
|---|---|---|
$.nodejs.run | Execute Node.js scripts | Run NODE scripts |
$.shell.open | Execute external programs | Launch exe, open files |
$.http.get | HTTP GET request | Call APIs |
$.http.post | HTTP POST request | Call APIs |
$.webview.open | Open WebView window | Display web management interface |
$.nodejs.run
Execute Node.js script files.
Syntax
{
"action": "$.nodejs.run",
"args": ["script_path", "param1", "param2", ...]
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
args[0] | string | ✅ | Node.js script path |
args[1+] | string | Optional | Script parameters |
Path Rules
Relative path: Relative to script package directory
json"args": ["script.js", "arg1"] // Actual path: %APPDATA%/iClick/Scripts/ScriptID/script.jsAbsolute path: Full file path
json"args": ["C:\\Users\\Admin\\scripts\\task.js", "arg1"]
$.shell.open
Execute external programs or open files.
Syntax
{
"action": "$.shell.open",
"args": ["program_path", "param1", "param2", ...]
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
args[0] | string | ✅ | Program path |
args[1+] | string | Optional | Command line arguments |
Path Rules
Relative path: Relative to script package directory
json"args": ["Tool.exe", "arg1"] // Actual path: %APPDATA%/iClick/Scripts/ScriptID/Tool.exeAbsolute path: Full file path
json"args": ["C:\\Program Files\\MyApp\\app.exe", "arg1"]
$.http.get
Send HTTP GET request.
Syntax
{
"action": "$.http.get",
"args": ["URL", {query_params}, {headers}]
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
args[0] | string | ✅ | Request URL |
args[1] | object | Optional | Query parameters object |
args[2] | object | Optional | Request headers object |
$.http.post
Send HTTP POST request.
Syntax
{
"action": "$.http.post",
"args": ["URL", {request_body}, {headers}]
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
args[0] | string | ✅ | Request URL |
args[1] | object | Optional | Request body object |
args[2] | object | Optional | Request headers object |
$.webview.open
Open embedded WebView window.
Syntax
{
"action": "$.webview.open",
"args": ["URL", {window_options}]
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
args[0] | string | ✅ | URL address |
args[1] | object | Optional | Window options object |
Window Options
| Option | Type | Default | Description |
|---|---|---|---|
width | number | 800 | Window width (pixels) |
height | number | 600 | Window height (pixels) |
alwaysOnTop | boolean | false | Always on top |
resizable | boolean | true | Resizable |
maximizable | boolean | true | Maximizable |
minimizable | boolean | true | Minimizable |
maxWidth | number | - | Maximum width |
maxHeight | number | - | 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
| Variable | Description | Example Value |
|---|---|---|
$.deviceId | Currently selected device ID | "iPhone-12345" |
Use Cases
Magic variables are particularly useful for scenarios that require current context information: