Using variables and functions

Working with variables and functions is one of advantages of MouseRobot. There are many convenient ways to set, change and use value of variable. MouseRobot has many build-in functions to work with date and time, strings, Windows system variables, math and etc.

This article describes the basics of using variables and functions in MouseRobot.

Variables and functions are the special keywords in MouseRobot, designed to store and process data during task execution.

Variables

In the simplest case, the variable of MouseRobot is a word or phrase in braces (for example, {WindowsDirectory}). During task execution, the variable is replaced by its value.

There are two type of variables in MouseRobot:

  • Built-in variables, to which the program assigns values automatically
    • {LastProcess} - recently run program or command
    • {WindowsDirectory} - full path to the Windows directory
    • {TaskFileDirectory} - directory where task file in located
  • User variables, where the values are explicitly assigned in steps (for example, in the "Set variable or call function" step)
    • {my_var}, {var1}, {var2}, {my_document_name}

Functions

The functions take one or more parameters, on the values of which they calculate the result.

Examples:

  • {Sum (2,2)} adds two numbers and returns the result (in this case - "4")
  • {StrStarts(abcdef, abc)} checks if the string starts with a certain substring
  • {Range(1, 10)} - list of numbers from a given range
  • {ControlText({LastControl})} returns control text
  • {DateValue({Now})} extracts date

How to use variables and functions

You can use variables and functions in all functional steps and snippets (Windows Command, Search Object on the Screen, Mouse and Keyboard, Condition, Loop and others).

For example, in the step "Mouse and Keyboard":

Variables sample

The list of built-in variables and functions is given in the MouseRobot User Manual (Reference section), and for quick insertion, you can use the drop down menu of "Value" ("V") button:

Build-in variables and functions

© AutomationBox 2005-2011