Automate program using variables and functions

Working with variables and functions is one of advantages of MouseRobot automation program. There are many convenient ways to set, change and use a value of variable. MouseRobot automation program 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 automation program.

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


In the simplest case, the variable of MouseRobot automation program 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 automation program:

  • 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}


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


  • {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


Bookmark & Share


Subscribe to Blog

AutomationBox Blog



View all


I love MouseRobot! An actual macro style recorder that operates by function rather than by cursor location. This is way easier to use and understand than any other macro program.
Aitken Rendell, technical support consultant

I am web developer and typically I have a lot of programs open. With MouseRobot I can run the single script, and a few seconds later my work area is ready to go! This is amazing!
Phill Judd, web developer



November 11, 2010
New Feedback System


October 16, 2010
MouseRobot 2.0 released!

Download Now!


June 24, 2010

MouseRobot 2.0
(beta-version) available


June 21, 2010

Site design changed!


News Archive >>