<< Click to Display Table of Contents >> Navigation: Actions > Script tools > JavaScript/Node.js script > RoboTask object for node.js |
The RoboTask object for node.js is similar in functionality to the built-in COM object RoboTaskApp, but there are major differences. Note that the JavaScript/node.js language is case-sensitive.
Example of the object usage:
const { RoboTask } = require('robotask')
const rt = new RoboTask()
rt.log('Hello world!').then(()=>rt.disconnect())
The basic JavaScript/Node.js package also doesn't support Windows COM objects. You can use your node.js package with win32ole installed. In this case, you will be able to use the built-in RoboTask.App object directly.
RoboTask()
Constructor.
Creates RoboTask object.
Use:
rt = RoboTask()
autoDisconnect
Read-write property
Timeout in seconds. Timeout of automatic disconnection from RoboTask.
0 means permanent connection. In this case, the script won't finish until disconnect() is executed. The default is 3 seconds.
When calling methods or properties of the RoboTask object, the connection is automatic.
connect()
Method.
Connecting to the RoboTask
disconnect()
Method.
Disconnecting from RoboTask
connected
Read-only property
Returns RoboTask connection status: True or False
log(text)
Method.
Outputs the specified text to the task log in user message mode.
logInfo(text)
Method.
Outputs the specified text in the log in system message mode.
logWarning(text)
Method.
Outputs the specified text in the log in warning mode.
logError(text)
Method.
Outputs the specified text to the task log in error message mode
expandText(text)
Method.
Expands a string containing RoboTask variables and returns it.
For example, expression
rt.expand_text('Date and time now: {DateTimeToFormat({DateTime},yyyyy-mm-dd hh:nn:ss)}')
Will return a value like this:
Date and time now: 2021-04-08 16:33:21
addUserVar(name, value)
Method.
Creates RoboTask variable with NAME name and VALUE value.
setUserVar(name, value)
Method.
Sets the VALUE to RoboTask variable with name NAME.
delUserVar(name)
Method.
Deletes RoboTask variable named NAME.
version
Property.
Returns dictionary with fields:
plain - RoboTask text version. For example, "8.3"
major - major version (8)
minor - minor version (3)
taskCount
Property.
Returns the number of registered tasks in RoboTask.
taskInfo(num)
Method.
Returns task information by number or name (external name).
Method returns dictionary with fields:
•name - task name (title).
•ext_name - external name. You can use this name to refer to the task in the script
•enabled - True or False
•state - task state. Can have 5 values:
manual - the task has no triggering events, or its triggering events are disabled (see the enabled property). It waits to be run manually or from another task;
idle - the task has some enabled triggering events. It waits to be run automatically,
disabled - the task is disabled while editing,
running - the task is started and in progress,
stopped - the task received the stop command, but it is yet running. After the task is completely stopped, its status becomes either "manual" or "idle".
currentTask
Property.
Returns information about the current task.
The result is exactly the same as taskInfo method except that it returns information about the current task.
startTask(ext_name, params)
Method.
Start task by number or External Name.
Parameters
•ext_name - task number or external name
•params - parameters of the task to be launched. Empty string by default. Parameters can be set as text, one parameter per line :
parameter_name=parameter_value
runTask
Alias of startTask method
stopTask(ext_name)
Method.
Stops task with a specified number or External Name
Note that RoboTask only sends a signal to stop the task. The task will stop when the step that is currently in progress is completed.
enableTask(ext_name)
Method.
Changes task state by number or External Name to "enabled" and starts all "enabled" task triggers.
disableTask(ext_name)
Method
Changes task state by number or External Name to "disabled" and stops all active task triggers.
serviceMode
Property
Returns logical value.
True - RoboTask is running in service mode.
False - RoboTask is running in normal app mode.
windowHandle
Property
Returns the RoboTask's window handle that receives system messages.
Related Topics