System Variables


*Tip:  There are three types of variables in vTask:

    1) User Variables, such as %foo.   These are your variables.
    2) System Variables, such as {clipboard}.   These are read-only values.
    3) Environment Variables, such as %PATH%.   These are read-only operating system values.


The System Variables link is available in the Properties toolbox with every action. It performs many functions for your scripts, and can be used anywhere text can be entered in an Action's properties.

When clicked, System Variables provide these features in vTask:




User Variables
 

User and Environment Variables are described in detail on a dedicated User Variables help page.

When displaying the list of declared user variables, the lookup menu will place array expansion (such as %array[1], %array[2], etc) in the "External Scripts" menu. This is done to avoid over-filling the local variables list (and the array expansion is only accurate at runtime).


 
vTask Variables
 

"vTask Variables" are items of information that change while a script is running (script-specific data). For example, {loops} is the number of the current loop, and {currentstep} is the step number being executed.

{loop}Current Loop Number
{loop2}Current Loop Number (2-digit, 3-digit, etc)
{repeats}Repeats Countdown from "Set Run Repeat" action
{repeats2}Repeats Countdown (2-digit, 3-digit, etc)
{command}
or
{cmd}
The text of the last GUI element clicked for User Input
prompts, such as "Yes" or "Cancel".

See Custom Message Box for a listing of constants and examples
{command_id}
or
{cmd_id}
The return value from User Prompt: usually the last
button pressed: 1 = OK, etc.

For multiple button types, such as YES + NO + CANCEL,
this variable will the appropriate Windows constants
such as IDCANCEL, IDOK, etc.

See Custom Message Box for a listing of constants and examples
{logfile}vTask Log File
{currentstep}Current Step #
{failstep}Number of Last Failed Step
(in parent or child script)
{http_status} The last HTTP status code returned from the "HTTP Post" action
{totalsteps}Total Step Count in current script
{currentfile}Current File Tab
{filename}Current Script Name + Path
{filebasename}Current Script Name
{filepath}Current Script Path
{fileext}Current Script Extension
{cmdline}The Command Line Arguments
{vTask_exe}The full path to the vTask EXE
{vTask_dir}The full path to the vTask installation folder
{vTask_hwnd}The handle to the main vTask Window
{vTask_ver}The current vTask version number
Memory Variables
{1} - {9}
Memory Variables are similar to User Variables, since they can be set by a user in a script. However, they are kept only in memory, and never stored on the PC. This means that they are much faster than normal variables, and more secure since their data is not physically saved on a hard drive. Another way to think of Memory Variables is a way for you to directly access memory (RAM). Allocation and cleanup is handled by vTask. If you are a programmer, you may think of these as being the same as "register variables".

They can be set with the Save Output To property, and also with the Set Variable and Delete Variable actions. There is no limit to the amount of data they can store (limited only by the PC's memory).

Memory Variables are only visible inside of a single instance of vTask (local, not global). They are not accessible by external or called scripts. If you want to use it globally, copy the values to a User Variable where you can make it externally visible.

Because Memory Variables are locations inside of memory, and not User Variables, they do not appear in the "Variables" palette.



vTask Internal Data Structure

The method for accessing the raw data fields from vTask is:

{step[1].field_name}

where [1] is the 1-based step number.
Example:   {step[4].comment}

Output is limited to 256 characters.

Data Field Description Sample
    {step[1].action}The action name"Use Window"
    {step[1].category}The branch of the action3
    {step[1].image}The icon number for display10
    {step[1].text}Main text of the command"Untitled - Notepad"
    {step[1].options}Option text"Activate,First"
    {step[1].timeout}The timeout value3
    {step[1].comment}The comment text"Find the window"
    {step[1].value1}Optional parameters, depending on command 100, 150
    {step[1].value2}depends on command -
    {step[1].value3}depends on command -
    {step[1].value4}depends on command -
    {step[1].value5}depends on command -
    {step[1].value6}depends on command -
    {step[1].value7}depends on command -
    {step[1].value8}depends on command -
    {step[1].output}The "Output To" selection"Variable", "Display in Message", etc
    {step[1].output_option}The sub-option for the chosen output"%foo"
    {step[1].fail_mode}The Failure selection"Display Error and Continue"
    {step[1].fail_option}Options for the selected failure"Label Error"
    {step[1].fail_snapshot}Screen shot on failure0
    {step[1].fail_log}Log on failure0
    {step[1].grid_text_column}The field to display in the "Text" column of grid0
    {step[1].run_status}The type of step0=Normal
1=Skipped
2=Breakpoint
    {step[1].run_result}The result of last run attempt0=Not Run
1=Incomplete
2=Success
3=Failure
4=Failure, but Continue
    {step[1].run_attempts}Number of times step was attempted1
    {step[1].custom}The <custom> XML data tag value(user defined)




System Variables
 

"System Variables" is information that is specific to the PC and the Windows operating system, such as the current position of the mouse, or the location of the \SYSTEM32\ directory.

{linefeed}, {\n}Newline (LF, \n ASCII 10)
{return}, {\r}Return (CR, \r, ASCII 13)
{newline}, {\r\n}Newline for Files (CR+LF, \r\n)
{tab}, {\t}Tab (ASCII 9)
{Space}Space (ASCII 32)
{\FF}2-digit hexadecimal number, between {\00} (0) and {\FF} (255) for a binary BYTE value
{PAGE}, {\P}Page break when writing a PDF document

No text should follow on the same line
as the page break symbol "{\P}".
It must be at the end of a line (or on a line by itself)
{clipboard}Clipboard Text
{screen_x}Screen Width
{screen_y}Screen Height
{mouse_x}Current Mouse Vertical Position (1-based)
{mouse_y}Current Mouse Horizontal Position (1-based)
Window Information
{window_x}Current Window Left Position (1-based)
{window_y}Current Window Top Position (1-based)
{window_width}Current Window Width (1-based)
{window_height}Current Window Height (1-based)
{window}Current Window Title
{hwnd}Current Window Handle
{win_class}Current Window Class Name
{win_id}Current Window ID
{win_data}Current Window User Data
PC Information
{winver}Windows Version
{windir}Windows Directory
{sysdir}System Directory
{curdir}Current Directory
{programfiles}"Program Files" Folder
{desktop}Desktop Folder
{startmenu}Start Menu Folder
{documents}My Documents Folder
{appdata}Documents and Settings Folder
{path}PATH Environment Variable
{tempdir}Directory for Temporary Files
{tempfile}Unique Temporary Filename
Note that if a new temp file is created during a run,
it is not automatically deleted at the end of a run.
{username}Currently Logged in User
{language}The current language setting



Date/Time Variables
 

vTask can format the date and time according to your needs. For example, a common date string would be:

{weekday}, {month_name} {day}, {year} - "Tuesday, December 06, 2007"


*Tip:  See Date and Time Functions for calculating and modifying times. Dates and Times can be added and subtracted, just like in Excel.


{year}Year
{year2}Year (2-digit)
{year4}Year (4-digit)
{month}Month Number (01-12)
{month1}Month Number (1-12)
{month_name}Month Name
{month_abbr}Month Name (abbreviated)
{monthdays}Days in Month (28-31)
{weeknum}Calendar Week (1-52)
{day}Day of Month (1-31)
{dayofyear}Day of Year (1-365)
{weekday}Weekday Name
{weekday_abbr}Weekday Name (abbreviated)
{weekday1}Weekday Digit
0=Sunday, 1=Monday, etc
(same format as Windows SYSTEMTIME)
 
{hour}Hour (1-12)
{hour12}Hour (1-12)
{hour2}12-Hour (01-12)
{hour24}24-Hour (00-23)
{minute}Minute (00-59)
{minute1}Minute (0-59)
{second}Second (00-59)
{second1}Second (0-59)
{millisecond}Milliseconds (1000ths of a second)
{AMPM}AM / PM
 
{TODAY}Current date in local format
{TIME}Current time in local format
{NOW}Current date+time string
 
{timezone}Difference from UTC (hours)
{ticks}Time Snapshot (for benchmarking)



Keyboard System Keys
 

Allows you to insert system keys from the keyboard. "System keys" are usually non-printable characters such as the F1 or Caps Lock keys. These keys are only available with the Keyboard Action, since other actions don't access the keyboard.

One of the interesting entries for system keys is the {Delay} option, which allows you to pause between other keypresses. For example, A{delay=500}B would press [A], then pause for half a second, and then press [B]. This allows typing to occur more naturally than if all the keys are pressed instantly.

*Tip:  Three keys can be controlled for Press and Release movements: Alt, Shift, and Control. This allows you to simulate key combinations through the keyboard, such as Alt+F for the file menu {altdown}F{altup}, or Ctrl+Shift+F2 {ctrldown}{shiftdown}{F2}{shiftup}{ctrlup}.