Author Topic: Text Tokens in VA  (Read 3807 times)

Slan

  • Global Moderator
  • Newbie
  • *****
  • Posts: 29
Text Tokens in VA
« on: May 11, 2016, 08:07:00 pm »
As the question often gets asked, I thought I would put up a list of the text tokens that VA can use.
There is no voodoo magic here, these are ripped straight from the VA help file that comes with every download!

These are for version v1.5.8.19 (beta)

Text (and Text-To-Speech) Tokens

A VoiceAttack Token is a tag that can be used as a placeholder to represent a value in
places that use text (think of Tokens as mini functions). Tokens are surrounded by curly
brackets { } and will always contain a title that is case-sensitive : {DATE} or {CMD} or
{CLIP}. Tokens started their life in VoiceAttack for use in Text-To-Speech (TTS). Over
time, the uses for tokens grew and now they can be used in all sorts of places that require
text, such as file paths for launching apps and use in conditional statements. Some tokens
you may use a lot, others you may never use at all. Some are simple (like {DATE} ) and
some are way out there (like {EXP} ). An example of how to use the first token ( {TIME} ) is
below. It was used in TTS to help indicate the local time to the VoiceAttack user.

“The current time is now {TIME}”.

This value was put in the, 'Say Something with Text-To-Speech' action. When the action is
executed, VoiceAttack replaces the {TIME} tag with the local time (24 hour clock) :

“The current time is thirteen hundred hours”.

A variation of the {TIME} token is {time} (notice the lower case). This token will be
rendered as a 12 hour clock, so, “The current time is now {time}” would be rendered as
“The current time is now one o'clock” when the action is executed.

Some tokens are a little bit more complicated (or flexible, depending on how you look at it)
and contain parameters. An example of this would be the {RANDOM:lowValue:highValue}
token. The purpose of this token is to generate a random number within a range.
Notice that this token has TWO parameters : lowValue and highValue to represent the
lower and upper boundaries of the range (I believe its first use was to roll virtual, 'dice').
Notice also that the parameters are separated from the title (and other parameters) by
colons. As an example, let's say we want to generate a random number between 10 and
20. The token would look like this: {RANDOM:10:20}.

Using Text-To-Speech, your action could use the following statement :

“I am generating a random number and it is {RANDOM:10:20}”.

When the action is executed, VoiceAttack will generate the random number and replace
the tag, so the result would be something like, “I am generating a random number and it is
16”.

There are some tokens that take a variable name as a parameter, such as
{TXT:variableName}. When VoiceAttack encounters a token that accepts variable names
as parameters, it replaces the tag with the value in that variable. In the case of
{TXT:variableName}, VoiceAttack will get a text variable's value. {INT:variableName} will
get an integer variable's value. {BOOL:variableName} will get a boolean variable's value
(and so on). Let's say you set up a text variable called, 'myText' to have a value of, 'Dave'.
The token you would use to get the value from 'myText' would be {TXT:myText}. You could
use the token in a Text-To-Speech statement such as this:

“I'm sorry, {TXT:myText}, I'm afraid I can't do that.” When the action is executed, the
rendered statement would be, “I'm sorry, Dave, I'm afraid I can't do that.” Then, if you set
'myText' to have a value of, 'Sally' and execute the statement again, the rendered
statement would be, “I'm sorry, Sally, I'm afraid I can't do that.”.

Note: VoiceAttack's tokens work even when there are multiple entries for random TTS
statements. Remember, tokens are case-sensitive... {Time} will not be processed
properly, but, {TIME} or {time} will work just fine.

Below is a haphazard list of tokens in no particular order (mostly in the order they were
created… lol… sorry, I will do better at some point) :

{TIME} - The current time, expressed in a 24-hour clock.
{TIME:dateVariableName} - The indicated date variable's time, expressed in a 24-hour
clock.

{time} - The current time, expressed as a 12-hour clock.
{time:dateVariableName} - The indicated date variable's time, expressed as a 12-hour
clock.

{TIMEHOUR} - The hour of the current time, expressed in a 12-hour clock.
{TIMEHOUR:dateVariableName} - The hour of the indicated date variable's time,
expressed in a 12-hour clock.

{TIMEHOUR24} - The hour of the current time, expressed in a 24-hour clock.
{TIMEHOUR24:dateVariableName} - The hour of the indicated date variable's time,
expressed in a 24-hour clock.

{TIMEMINUTE} - The minute of the current time.
{TIMEMINUTE:dateVariableName} - The minute of the indicated date variable's time.

{TIMESECOND} - The second of the current time.
{TIMESECOND:dateVariableName} - The second of the indicated date variable's time.

{TIMEAMPM} - The AM/PM designation of the current time.
{TIMEAMPM:dateVariableName} - The AM/PM designation of the indicated date
variable's time.

{DATE} - The current date, formatted as follows: 'April 3, 2015'.
{DATE:dateVariableName} - The indicated date variable, formatted as follows: 'April 3,
2015'.

{DATEYEAR} - The current year as a number (2015, 2016, 2017, etc).
{DATEYEAR:dateVariableName} - The indicated date variable's year as a number (2015,
2016, 2017, etc).

{DATEDAY} - The current day of the month as a number.
{DATEDAY:dateVariableName} - The indicated date variable's day of the month as a
number.

{DATEMONTH} - The current month, spelled out ('April', 'May', 'June', etc).
{DATEMONTH:dateVariableName} - The indicated date variable's month, spelled out
('April', 'May', 'June', etc).

{DATEMONTHNUMERIC}
- The current month as a number (April would be 4, May would
be 5, June would be 6, etc).
{DATEMONTHNUMERIC:dateVariableName} - The indicated date variable's month as a
number (April would be 4, May would be 5, June would be 6, etc).

{DATEDAYOFWEEK} - The current day of the week spelled out ('Monday', 'Tuesday',
'Wednesday', etc).
{DATEDAYOFWEEK:dateVariableName} - The indicated date variable's day of the week
spelled out ('Monday', 'Tuesday', 'Wednesday', etc).

{DATETICKS}
– The current date as ticks. This will be a numeric value expressed as text
that can be used for comparison.
{DATETICKS:dateVariableName} – The indicated date variable as ticks. This will be a
numeric value expressed as text that can be used for comparison.

{CMD} - The name of the currently-executing command.

{CMDACTION} - The method by which the current command was executed. The possible
results are, 'Spoken', 'Keyboard', 'Joystick', 'Mouse', 'Profile', 'External', 'Unrecognized' and
'Other'. The value will be, 'Spoken' if the command was executed by a spoken phrase,
'Keyboard' if the command was executed using a keyboard shortcut, 'Joystick' if executed
by a joystick button, 'Mouse' if executed by a mouse button click and 'Profile' if the
command was executed on profile load (from the command indicated in the profile options
screen). The value will be 'External' if the command is executed from a command line.
'Unrecognized' will be the value if the command was executed using the unrecognized
phrase catch-all command in the profile options screen. 'Other' is reserved.

{CMD_BEFORE} - When using wildcards in spoken phrases, this is the text that occurs
before the wildcard phrase. For example, if using, '*rocket*' as your wildcard phrase and
you say, 'i am going for a ride in my rocket ship' {CMD_BEFORE} will contain, 'i am going
for a ride in my' and {CMD_AFTER} will contain 'ship'. This token does not have to be set
prior to using.

{CMD_AFTER} - When using wildcards in spoken phrases, this is the text that occurs
after the wildcard phrase.

{LASTSPOKENCMD} - This provides the last-spoken command phrase. Useful from
within subcommands where you need to know what was said to invoke the root command,
or if you need to know what was spoken prior to the current command.

{ISLISTENINGOVERRIDE}
- If the executing command was invoked by a listening
override keyword (for instance, if you executed the command by saying, 'Computer, Open
Door' instead of, 'Open Door') the result will be, '1'. Otherwise, the result will be, '0'.

{ISCOMPOSITE} - If an executing command is composite (where there is a prefix and a
suffix), the return of this token will be, '1'. Otherwise, it will be, '0'.

{PREFIX} - If an executing command is composite (where there is a prefix and a suffix),
this token will be replaced with the prefix portion of the command. If called in a non-
composite command, this will result in a blank string.
{SUFFIX} - If an executing command is composite (where there is a prefix and a suffix),
this token will be replaced with the suffix portion of the command. If called in a non-
composite command, this will result in a blank string.

{COMPOSITEGROUP} - If an executing command is composite (where there is a prefix
and a suffix), this token will return the group value if it is being used.

{CATEGORY} - This returns the category of the executing command. If this token is used
on a composite command (a command using a prefix and suffix), the result will be the
category of the prefix and the category of the suffix separated by a space. For the
individual parts of a composite category, see, '{PREFIX_CATEGORY}' and
'{SUFFIX_CATEGORY}'.

{PREFIX_CATEGORY} - This returns the prefix category of the executing command (if the
executing command is a composite command).

{SUFFIX_CATEGORY} - This returns the suffix category of the executing command (if the
executing command is a composite command).

{PROFILE}
- The name of the currently-loaded profile.

{RANDOM:lowValue:highValue}
- A random number between a low number and a high
number (inclusive) will be generated. For example, {RANDOM:1:100} will pick a number
between 1 and 100. {RANDOM:77:199} will pick a number between 77 and 199.

***Important Note: Conditions have been renamed to Small Integer. The token
{SMALL:variableName} (see below) has been created to handle small integer variables.
The {COND:conditionName} and {CONDFORMAT:conditionName} have been left in for
backward compatibility (you can use either token interchangeably, since they both access
the same values).

{COND:conditionName}
- The numeric value stored in a condition variable will be
retrieved. For example, if you have a condition called, 'My Condition', you would use,
{COND:My Condition}. Note that with this token, everything to the left of the colon is case-
sensitive. Everything to the right is not ({COND:mY cOnDitIon} would work the same
way ;) ) This token must be set prior to using, otherwise the value will be, 'NOT SET' when
accessed. NOTE: The comma formatting of this token has been removed. See,
'{CONDFORMAT}' token, below).

{CONDFORMAT:conditionName} - This returns the same value as {COND}, but the value
is formatted with commas (for TTS). This used to be the default behavior of {COND}, but,
since the introduction of the {EXP} token, this token had to be created.

{SMALL:variableName} - The numeric value stored in a small integer variable will be
retrieved. For example, if you have a variable called, 'My Small Int', you would use,
{SMALL:My Small Int}. Note that with this token, everything to the left of the colon is case-
sensitive. Everything to the right is not ({SMALL:mY sMaLL InT} would work the same way
 ;) ) The referenced variable must be set prior to using, otherwise the value will be, 'NOT
SET' when accessed. NOTE: The comma formatting of this token has been removed.
See, '{SMALLFORMAT}' token, below).

{SMALLFORMAT:variableName} - This returns the same value as {SMALL}, but the value
is formatted with commas (for TTS). This used to be the default behavior of {SMALL}, but,
since the introduction of the {EXP} token, this token had to be created.

{INT:variableName} - The numeric value stored in an integer variable will be retrieved.
For example, if you have a variable called, 'My Int', you would use, {INT:My Int}. Note that
with this token, everything to the left of the colon is case-sensitive. Everything to the right
is not ({INT:mY InT} would work the same way ;) ) The referenced variable must be set
prior to using, otherwise the value will be, 'NOT SET' when accessed. NOTE: The comma
formatting of this token has been removed. See, '{INTFORMAT}' token, below).

{INTFORMAT:variableName} - This returns the same value as {INT}, but the value is
formatted with commas (for TTS). This used to be the default behavior of {INT}, but,
since the introduction of the {EXP} token, this token had to be created.

{DEC:variableName} - The numeric value stored in a decimal variable will be retrieved.
For example, if you have a variable called, 'My Decimal', you would use,
{DEC:My Decimal}. Note that with this token, everything to the left of the colon is case-
sensitive. Everything to the right is not ({DEC:mY DeCImal} would work the same way ;) )
The referenced variable must be set prior to using, otherwise the value will be, 'NOT SET'
when accessed.

{BOOL:variableName} - The text representation of the boolean value will be retrieved. If
the variable value is true, the token will be replaced with, 'True'. If false, the token will be
replaced with, 'False'. The referenced variable must be set prior to using, otherwise the
value will be, 'NOT SET' when accessed.

{TXT:variableName} - The text value stored in a text variable will be retrieved. This works
the same way as all the other types (above), except that... well... you get the idea. The
variable referenced by this token must be set prior to using, otherwise the value will be,
'NOT SET' when accessed.

{TXT:variableName:defaultValue}
- The text value stored in a text variable will be
retrieved (just like above), but, if the value results in, 'Not Set', the text in the, 'defaultValue'
parameter will be used. This referenced variable does not have to be set prior to using
(since the default value will be used instead).

{TXTURL:variableName}
- The text value stored in a text variable will be retrieved (again,
just like above), but the result will be URL encoded.

{TXTRANDOM:value} - This token will do a simple randomize of its text contents. For
example, a token could be used in TTS to say, 'I love {TXTRANDOM:food;animals;jewelry}'
and the result would be, 'I love animals' or, 'I love food' or, 'I love jewelry'. Note that the,
'value' portion can be another token, however, if you want to randomize randomized
tokens, it is suggested that you use text value variables to store the values, otherwise it
may get a little out of sorts. Experiment with this one, since the permutations for testing
are a little out there :)

{TXTLEN:variableName} - This will return the length of the text variable's value.

{TXTUPPER:variableName}
- This will return the text variable's value in upper case.

{TXTLOWER:variableName} - This will return the text variable's value in lower case.

{TXTTRIM:variableName}
- This will return the text variable's value with spaces removed
from the beginning and end.
{TXTREPLACE:variableSource:From:To} - This will return the text variable's value with
the text indicated in From as To. For example: Variable, 'myVariable' value set to, 'This is
a test'.
{TXTREPLACE:myVariable:test:monkey} renders as 'This is a monkey'.
Note: The second and third parameters are literal values and not variables.
Note: This token has been deprecated and is no longer supported. It is left in to keep
older commands from breaking. Please use {TXTREPLACEVAR} instead.

{TXTREPLACEVAR:variableSource:variableFrom:variableTo}
-This will return the text
variable's value with the text indicated in variableFrom as the value in variableTo. For
example: Variable, 'myVariable' value set to, 'This is a test'. Variable, ‘mySearch’ value set
to, ‘test’ and variable, ‘myReplacement’ value set to, ‘monkey’.
{TXTREPLACEVAR:myVariable:mySearch:myReplacement} renders as, ‘This is a
monkey’.
Note: This is the updated version of {TXTREPLACE}

{TXTNUM:variableName} - This will attempt to remove all characters except numeric
(0-9, ., -).

{TXTALPHA:variableName}
- This will attempt to remove all numeric characters (0-9).

{TXTTITLE:variableName} - This will attempt to title case the value (for supported
locales). For example, 'war and peace' becomes, 'War And Peace'. Yes… I know that's
not proper title case (at lease in English), but it's as close as the framework will allow
without linguistic rules. Sorry!

{TXTCONCAT:variableName1:variableName2} - This will attempt to concatenate the text
in variable 2 to the text of variable 1. For instance, let's say var1 is set to “Good” and var2
is set to “ Morning” (note the space). {TXTCONCAT:var1:var2} will yield, “Good Morning”.
If variable 1 or variable 2 are “Not set”, the result will be, “Not set”.

{TXTPOS:txtVarOf:txtVarIn:intVarStart} - this will return the position of text (txtVarOf)
within more text (txtVarIn) starting at a given point (intVarStart). This uses three variables
that MUST BE SET prior to using. The text search is case-sensitive. If the text is found,
the result will be the zero-based index of the start of the text. Otherwise, if the text is not
found the result will be “-1”. For example, if you are wanting to find the word, 'active' in the
phrase, 'all systems active', you will first need to set a text variable to the word, 'active'. In
this example, that variable is called, 'txtFindActive'. Next, you will need to set a second text
variable to the phrase, 'all systems active'. That variable is called, 'txtStatus'. Next, you
will need to set a variable to indicate the position where you would like to start searching.
Since you would like to search the entire phrase, you will need to set this variable to zero.
So, a third variable, 'intPosition' needs to be set to zero (see note on this below). You will
then use this token with the three variables like this:
{TXTPOS:txtFindActive:txtStatus:intPosition}. The result will be “12”, as the position of
'active' appears in position 12 (the phrase actually starts at the 13th character, but we are
using a zero-based positioning system).
Note: if txtVarIn or txtVar of are not set, the result will be, '-1'. If intVarStart is not set, 0 is
assumed (for convenience).

{ACTIVEWINDOWTITLE} - Returns the active window's title text.

{ACTIVEWINDOWPROCESSNAME}
- Returns the active window's process name (the
one you see in Task Manager).

{ACTIVEWINDOPROCESSID} - Returns the active window's process id (the one you see
in Task Manager details).

{ACTIVEWINDOWWIDTH} - Returns the active window's width. Helps with
resizing/moving.

{ACTIVEWINDOWHEIGHT}
- Returns the active window's height. Helps with
resizing/moving.

{ACTIVEWINDOWTOP} - Returns the active window's top (Y coordinate). Helps with
resizing/moving.

{ACTIVEWINDOWLEFT} - Returns the active window's left (X coordinate). Helps with
resizing/moving.

{ACTIVEWINDOWRIGHT} - Returns the active window's right (left + width). Helps with
resizing/moving.

{ACTIVEWINDOWBOTTOM}
- Returns the active window's bottom (top + height). Helps
with resizing/moving.

{WINDOWEXISTS:textVariable} – Returns “1” if a window with the title specified in
textVariable exists. Returns “0” if not. Note that this can take wildcards (*) for window titles
that change. For instance, if textVariable contains '*notepad*' (without quotes), the search
will look for a window that has a title that contains 'notepad'.

{WINDOWCOUNT:textVariable} – Returns “1” or more if windows with the title specified in
textVariable exist. Returns “0” if there are none. Note that this can take wildcards (*) for
window titles that change. For instance, if textVariable contains '*notepad*' (without
quotes), the search will look for windows that have a title that contains 'notepad'.

{WINDOWTITLEUNDERMOUSE}
– Returns the title for the window that is currently
located under the mouse.

{WINDOWPROCESSUNDERMOUSE} – Returns the process name for the window that is
currently located under the mouse.

{MOUSESCREENX} - Returns the X coordinate of the mouse position as it relates to the
screen. Zero would be the top-left corner of the screen.

{MOUSESCREENY}
- Returns the Y coordinate of the mouse position as it relates to the
screen. Zero would be the top-left corner of the screen.

{MOUSEWINDOWX}
- Returns the X coordinate of the mouse position as it relates to the
active window. Zero would be the top-left corner of the window.

{MOUSEWINDOWY}
- Returns the Y coordinate of the mouse position as it relates to the
active window. Zero would be the top-left corner of the window.

{CAPSLOCKON} - Returns “1” if the caps lock key is locked. Returns “0” if not.

{NUMLOCKON} - Returns “1” if the numlock key is locked. Returns “0” if not.

{SCROLLLOCKON}
- Returns “1” if the scroll lock key is locked. Returns “0” if not.

{CLIP} - This token will be replaced by whatever is in the Windows clipboard, as long as
what is in the clipboard is a text value. Note: This value can also be set within VoiceAttack
by using the 'Set a text value to the Windows clipboard' action.

{DICTATION} - This token will be replaced by whatever is in the dictation buffer, without
any formatting. So, if you said, 'This is a test of the emergency broadcast system' and then
later said 'this is only a test', the result would be 'This is a test of the emergency broadcast
system this is only a test'.

{DICTATIONON}
- This token returns “1” if dictation mode is on, and “0” if it is off.

{DICTATION:options} - This token is an attempt to offer some basic touch up to whatever
is in the dictation buffer. The speech recognition engine may do all kinds of heinous things
to your text (as you will see... lol ;) ) First, lets talk about the options. The option examples
below will be used with as if your dictation buffer was filled first by saying 'This is a test of
the emergency broadcast system' and then later saying 'this is only a test'.
The options are:

PERIOD - This puts a period in for you at the end of each line (so you don’t have to
constantly say, 'period' to the speech engine). The rendered output would be:
'This is a test of the emergency broadcast system. this is only a test.'.

CAPITAL - Capitalizes the first character of every line (since the speech engine may or
may not do it for you... o_O). The rendered output would be:
'This is a test of the emergency broadcast system This is only a test'.

LATEST - Only display the last thing you said. In the example, you would get 'this is only a
test'.

UPPERCASE - Converts all characters to upper case :
'THIS IS A TEST OF THE EMERGENCY BROADCAST SYSTEM THIS IS ONLY A TEST'

LOWERCASE - Converts all characters to lower case :
'this is a test of the emergency broadcast system this is only a test'

NEWLINE - Makes sure each phrase is on its own line (note that it wont show up this way
if you write to the log... the log doesn't care about new lines). Rendered output would be:
'This is a test of the emergency broadcast system
this is only a test.'.

SPACEX
- Replace the, 'X' with an integer number, and that many extra spaces will be
placed at the end of each phrase. The default is one space. So, if you use
{DICTATION:SPACE4}, the rendered output will be
'this is a test of the emergency broadcast system this is only a test'.

You can use any or all of the options, in any order, separated by a colon. They are not
case-sensitive. So, if you simply wanted to add a period to the end of each spoken
dictation phrase and ensure that the first character is always capitalized, you would use
{DICTATION:PERIOD:CAPITAL}. The above example would be rendered as :
'This is a test of the emergency broadcast system. This is only a test.'.
If you wanted to also make it so that a line feed is placed between lines,
you can use {DICTATION:PERIOD:CAPITAL:NEWLINE}. You will then get:
'This is a test of the emergency broadcast system.
This is only a test.'.

{EXP:expression} - Currently experimental, the expression token will evaluate a typed-out
expression (parenthesis and all, for order of operation) and return the value as text.
Comparison expressions can be used on both text and numeric values (including numeric
variables such as Integer, Small Integer and Decimal). Arithmetic expressions can be
performed on numeric values. Values intended to be used for numeric variables can then
be converted using their various, 'Convert Text/Token' option in each of the set value
screens (for use in condition blocks (note that the result values can be decimal values
when dividing). There are several ways to use expressions as outlined below.

Evaluating Arithmetic Expressions
The expression token can be used to evaluate arithmetic expressions like so:
{EXP: ((5 + 5) - 2) * 10} (evaluates to, '80')

Accepted arithmetic operators: +, -, * (multiplication), / (division), % (modulus).

This token also accepts tokens to be evaluated. So, if you have a text value myText1 and
it is set to '100' and an integer variable myInt1 that is 200, you can have a mixed
expression of, {EXP:({TXT:myText1} + {INT:myInt1}) * 2} that results in '600'.

Numeric Comparisons
You can do numeric comparisons using expressions as well:
{EXP: {TXT:myText1} = {INT:myInt1} } (evaluates to, '0' (false))
Comparison expressions return either '1' for true, or '0' for false.

Accepted comparison operators: =, <, >, <= (less than or equal), >= (greater than or equal),
<> (not equal).

You may also use, 'And', 'Or', 'Not':
{EXP: ('cat' = 'dog') And Not (20 = 30) } (evaluates to, '0' (false))
{EXP: ('cat' = 'dog') Or (20 = 30) } (evaluates to, '0' (false))
{EXP: Not ('cat' = 'dog') } (evaluates to, '1' (true))

Evaluating Text Comparisons
The expression token can evaluate text.

{EXP: 'all your base are belong to us' = 'hello'} (evaluates to, '0' (false)).

{EXP: 'all your base are belong to us' <> 'hello'} (evaluates to, '1' (true)).

Just like numeric comparisons, comparison expressions return either '1' for true, or '0' for
false.

Note that you have to enclose the text in single quotes (the quotes even need to be around
tokens if the token value itself does not have quotes). If the text contains single quotes,
they need to be doubled up to be used in expression tokens:
{EXP:'catcher''s mitt' = 'pitcher''s mitt'}

Text comparisons are not case sensitive.

Accepted comparison operators: =, <, >, <= (less than or equal), >= (greater than or equal),
<> (not equal). You may also use, 'And', 'Or', 'Not'.

You can use, 'LIKE' as part of your text comparison expressions. The text that you are
comparing to needs to have asterisks in various places in order to indicate the type of
comparison to make (wildcards).

Asterisks around the text indicate, 'contains':
{EXP: 'rocket ship' LIKE '*rocket*'} (evaluates to '1' (true) because the text contains,
'rocket')

Asterisks at the end indicate, 'starts with' :
{EXP: 'rocket ship' LIKE 'ship*'} (evaluates to '0' (false), since the text does not start with,
'ship')

Asterisks at the beginning indicate, 'ends with':
{EXP: 'rocket ship' LIKE '*ship'} (evaluates to '1' (true), since the text ends with 'ship')

No asterisks indicate exact match (just like using, '=').

Other Expression Abilities

You can concatenate text by using, '+':
{EXP: 'welcome' + ' ' + 'captain' } evaluates to 'welcome captain'.

You can use, 'TRIM', 'SUBSTRING', 'LEN' and, 'IIF' (immediate, 'if')).

TRIM removes any blank spaces around text :
{EXP: TRIM(' my trimmed text ') } evaluates to 'my trimmed text'

SUBSTRING(start position, length) gets just the portion of the text you are wanting:
{EXP: SUBSTRING('let the good times roll', 9, 4) } evaluates to, 'good'.
Note that the start is 1-based (not zero-based).

LEN gives the length of the text:
{EXP: LEN('let the good times roll') } evaluates to 23.

IIF(expression, true part, false part) allows you to evaluate an expression and get one of
two values depending on the result:
{EXP: IIF('cat' = 'dog', 10, 20) } evaluates to, '20'
{EXP: IIF('cat' <> 'dog', 10, 20) } evaluates to, '10'
myCondition1 is 100 and myCondition2 is 200 :
{EXP: IIF({INT:myInt1} > {INT:myInt2}, 'Blue', 'Green') } evaluates to, 'Green'.

VoiceAttack State Tokens

State tokens will allow you to test various conditions that are occurring within VoiceAttack.
These can be handy by allowing you to modify the flow of your command actions based on
the state of your devices. For instance, you can check (with a conditional (if) statement) if
the right mouse button is down when I say, 'fire weapons', missiles are fired instead of
photons (lol). Also, if the 'x' button is down, fire both photons and missiles. You can also
monitor the position of your sliders or X, Y and Z positions of the joystick itself to create
some interesting, 'triggers' using loops and conditional (if) statements.

{STATE_KEYSTATE:key} - This token checks to see if a particular key is pressed down or
not. The, 'key' parameter can be any key you can type in a token: 'A', 'B', 'C', 'ß', 'ö', 'ñ', 'ç',
as well as keys you can't type in a token: ENTER, TAB, LCTRL, ARROWR (see section
later in this document titled, 'Key State Token Parameter Values' for the full list).

So, if you want to test to see if the F10 key is down, just use the following token:
{STATE_KEYSTATE:F10}. To test for the letter 'A', just use this token:
{STATE_KEYSTATE:A}. If a keyboard key is down, the replaced value of the token will be
"1". If the key is not down, the value will be "0".

{STATE_LEFTMOUSEBUTTON}
{STATE_RIGHTMOUSEBUTTON}
{STATE_MIDDLEMOUSEBUTTON}
{STATE_FORWARDMOUSEBUTTON}
{STATE_BACKMOUSEBUTTON}
- Each of these tokens test to see if a mouse button is
being pressed. If you want to test for the right mouse button, use token

{STATE_RIGHTMOUSEBUTTON}. If the mouse button is pressed down, the replaced
value will be "1". If the mouse button is not pressed, the value will be "0".

{STATE_AUDIOLEVEL} - This token indicates the currently reported audio level from the
speech engine. The replaced value will be from “0” to “100”.

{STATE_LISTENING} - this token tests to see if VoiceAttack is, 'listening'. If, 'listening' is
on, the replaced value will be "1". If, 'listening' is off, the replaced value will be "0".

{STATE_SHORTCUTS} - this token tests to see if VoiceAttack's shortcuts are enabled. If
shortcuts are enabled, the replaced value will be "1". Otherwise, the replaced value will be
"0".

{STATE_MOUSESHORTCUTS} - this token tests to see if VoiceAttack's mouse button
shortcuts are enabled. If they are enabled, the replaced value will be "1". Otherwise, the
replaced value will be "0".

{STATE_CPU:coreNumber}
{STATE_CPU}
- these will return your your cpu usage. {STATE_CPU} will return the
average for all cores. The value returned will be from “0” to “100”.
{STATE_CPU:coreNumber} will allow you to specify a particular core. For instance,
{STATE_CPU:5} will get the cpu usage for core 5.

{STATE_RAMTOTAL} - this will return the total RAM on your system in bytes.

{STATE_RAMAVAILABLE} - this will return the available RAM on your system in bytes.

{STATE_FILEEXISTS:textVariable} - this will return “1” if the file indicated in the text
variable exists, or “0” if it does not.

{STATE_DIRECTORYEXISTS:textVariable}
- this will return “1” if the directory indicated in
the text variable exists, or “0” if it does not.

Joystick State Token Reference
This section is for the joystick state tokens. Everything below the buttons and POV are
lifted directly from DirectX states. Each state value may or may not be available for your
device, so, your mileage may vary.

{STATE_JOYSTICKBUTTONS} - this token tests to see if VoiceAttack's joystick buttons
are enabled. If joystick buttons are enabled, the replaced value will be "1". Otherwise, the
replaced value will be "0".

{STATE_JOYSTICK1BUTTON:buttonNumber}
{STATE_JOYSTICK2BUTTON:buttonNumber}
- these two tokens test to see if particular
joystick's button is down or not. The, 'buttonNumber' parameter is the number of the button
on the desired stick. To test if button 10 is down on joystick 2, just use this token:
{STATE_JOYSTICK2BUTTON:10}. Once again, if the button is down on the tested
stick, the replaced value will be "1". If the button is not down, the value will be "0".
Point of View (Hat) Controllers – (Note: there are up to 4 available POV controllers per
stick)

{STATE_JOYSTICK1POVENABLED}
{STATE_JOYSTICK2POVENABLED}
- this token indicates whether or not POV is enabled
for the indicated stick. If enabled the replaced value will be “1”. Otherwise, the replaced
value will be “0”.

{STATE_JOYSTICKXPOVYTYPE}
- Use this token to find out how the POV is being used
by VoiceAttack (as indicated in the joystick options on the options page). X indicates the
stick number (1 or 2) and Y indicates the POV controller (1-4). So, to get the POV type for
the second POV controller on stick 1, use : {STATE_JOYSTICK1POV2TYPE}. The
replaced value will be one of the following:
“-1” - POV not available.
“0” - POV available, not turned on in settings.
“1” - POV acts as on/off switch (any direction will cause the POV to indicate as switched.
“2” - POV acts as two-directional switch (up or down).
“3” - POV acts as two-directional switch (left or right).
“4” - POV acts as four-directional switch (up, down, left, right).
“8” - POV acts as eight-directional switch (up, up right, right, down right, down, down left,
left, up left).

{STATE_JOYSTICKXPOVY} - This token is used to get the direction pressed by the POV
controller. X indicates the stick (1 or 2). Y indicates the POV controller (1-4). So, to get the
position value for stick 1, POV controller 2, use: {STATE_JOYSTICK1POV2}.
The replaced value will be “CENTER”, “UP”, “UPRIGHT”, “RIGHT”, “DOWNRIGHT”,
“DOWN”, “DOWNLEFT”, “LEFT”, “UPLEFT” depending on the direction pushed, or, “-1” if
the POV controller is unavailable. Note that certain directions will only be available due to
the type of POV setup in options (see the token above for getting the POV type). For POV
type “1” (POV is on/off switch), the only position that will be indicated and that you should
test for is, “UP” (this is for speed reasons). For “2” (POV is up/down only), “UP” and
“DOWN” are indicated. For “3” (POV is left/right only), “LEFT” and “RIGHT” are indicated.
For “4” (four-direction), “LEFT”, “RIGHT”, “UP” and “DOWN” are indicated. For “8” (eight-
direction), all eight directions are available.

DirectX Joystick States (simply DirectX query, not tracked by VoiceAttack for
managing events):

{STATE_JOYSTICKXPOVY_NUMERIC} - This token is used to get the numeric value
presented by the POV controller. X indicates the stick (1 or 2). Y indicates the POV
controller (1-4). So, to get the position value for stick 1, POV controller 2, use:
{STATE_JOYSTICK1POV2}. The value will usually be “-1” (some drivers may report
“65535”) if the POV is centered, or “0” to “35999” as the POV is pressed in a direction. You
can use this token if the VoiceAttack, 'switch' model does not fit your needs.

{STATE_JOYSTICK1X}
{STATE_JOYSTICK2X}
- This token is used to indicate the X value of the indicated
joystick. The replaced value is “0” at minimum and “65535” at maximum. This value will
be “-1” if the stick is unavailable.

{STATE_JOYSTICK1Y}
{STATE_JOYSTICK2Y}
- This token is used to indicate the Y value of the indicated
joystick. The replaced value is “0” at minimum and “65535” at maximum. This value will
be “-1” if the stick is unavailable.

{STATE_JOYSTICK1Z}
{STATE_JOYSTICK2Z}
- This token is used to indicate the Z value of the indicated
joystick. The replaced value is “0” at minimum and “65535” at maximum. This value will
be “-1” if the stick is unavailable.

{STATE_JOYSTICK1ROTATIONX}
{STATE_JOYSTICK2ROTATIONX}
- This token is used to indicate the rotation X value of
the indicated joystick. The replaced value is “0” at minimum and “65535” at maximum.
This value will be “-1” if the stick is unavailable.

{STATE_JOYSTICK1ROTATIONY}
{STATE_JOYSTICK2ROTATIONY}
- This token is used to indicate the rotation Y value of
the indicated joystick. The replaced value is “0” at minimum and “65535” at maximum.
This value will be “-1” if the stick is unavailable.

{STATE_JOYSTICK1ROTATIONZ}
{STATE_JOYSTICK2ROTATIONZ}
- This token is used to indicate the rotation Z value of
the indicated joystick. The replaced value is “0” at minimum and “65535” at maximum.
This value will be “-1” if the stick is unavailable.

{STATE_JOYSTICK1ACCELERATIONX}
{STATE_JOYSTICK2ACCELERATIONX}
- This token is used to indicate the acceleration
X value of the indicated joystick. This value will be “-1” if the stick is unavailable.

{STATE_JOYSTICK1ACCELERATIONY}
{STATE_JOYSTICK2ACCELERATIONY}
- This token is used to indicate the acceleration
Y value of the indicated joystick. This value will be “-1” if the stick is unavailable.

{STATE_JOYSTICK1ACCELERATIONZ}
{STATE_JOYSTICK2ACCELERATIONZ}
- This token is used to indicate the acceleration
Z value of the indicated joystick. This value will be “-1” if the stick is unavailable.

{STATE_JOYSTICK1ANGULARACCELERATIONX}
{STATE_JOYSTICK2ANGULARACCELERATIONX}
- This token is used to indicate the
angular acceleration X value of the indicated joystick. This value will be “-1” if the stick is
unavailable.

{STATE_JOYSTICK1ANGULARACCELERATIONY}
{STATE_JOYSTICK2ANGULARACCELERATIONY}
- This token is used to indicate the
angular acceleration Y value of the indicated joystick. This value will be “-1” if the stick is
unavailable.

{STATE_JOYSTICK1ANGULARVELOCITYZ}
{STATE_JOYSTICK2ANGULARVELOCITYZ}
- This token is used to indicate the angular
acceleration Z value of the indicated joystick. This value will be “-1” if the stick is
unavailable.

{STATE_JOYSTICK1ANGULARVELOCITYX}
{STATE_JOYSTICK2ANGULARVELOCITYX}
- This token is used to indicate the angular
velocity X value of the indicated joystick. This value will be “-1” if the stick is unavailable.

{STATE_JOYSTICK1ANGULARVELOCITYY}
{STATE_JOYSTICK2ANGULARVELOCITYY}
- This token is used to indicate the angular
velocity Y value of the indicated joystick. This value will be “-1” if the stick is unavailable.

{STATE_JOYSTICK1ANGULARVELOCITYZ}
{STATE_JOYSTICK2ANGULARVELOCITYZ}
- This token is used to indicate the angular
velocity Z value of the indicated joystick. This value will be “-1” if the stick is unavailable.

{STATE_JOYSTICK1FORCEX}
{STATE_JOYSTICK2FORCEX}
- This token is used to indicate the force X value of the
indicated joystick. This value will be “-1” if the stick is unavailable.

{STATE_JOYSTICK1FORCEY}
{STATE_JOYSTICK2FORCEY}
- This token is used to indicate the force Y value of the
indicated joystick. This value will be “-1” if the stick is unavailable.

{STATE_JOYSTICK1FORCEZ}
{STATE_JOYSTICK2FORCEZ}
- This token is used to indicate the force Z value of the
indicated joystick. This value will be “-1” if the stick is unavailable.

{STATE_JOYSTICK1TORQUEX}
{STATE_JOYSTICK2TORQUEX}
- This token is used to indicate the torque X value of the
indicated joystick. This value will be “-1” if the stick is unavailable.

{STATE_JOYSTICK1TORQUEY}
{STATE_JOYSTICK2TORQUEY}
- This token is used to indicate the torque Y value of the
indicated joystick. This value will be “-1” if the stick is unavailable.

{STATE_JOYSTICK1TORQUEZ}
{STATE_JOYSTICK2TORQUEZ}
- This token is used to indicate the torque Z value of the
indicated joystick. This value will be “-1” if the stick is unavailable.

{STATE_JOYSTICK1VELOCITYX}
{STATE_JOYSTICK2VELOCITYX}
- This token is used to indicate the velocity X value of
the indicated joystick. This value will be “-1” if the stick is unavailable.

{STATE_JOYSTICK1VELOCITYY}
{STATE_JOYSTICK2VELOCITYY}
- This token is used to indicate the velocity Y value of
the indicated joystick. This value will be “-1” if the stick is unavailable.

{STATE_JOYSTICK1VELOCITYZ}
{STATE_JOYSTICK2VELOCITYZ}
- This token is used to indicate the velocity Z value of
the indicated joystick. This value will be “-1” if the stick is unavailable.

{STATE_JOYSTICKXSLIDERY} - This token is used to indicate the slider value. X
indicates the stick number (1 or 2) and Y indicates the control number (1 or 2). If the
control is not available the replaced value will be “-1”.

{STATE_JOYSTICKXACCELERATIONSLIDERY}
- This token is used to indicate the
acceleration slider value. X indicates the stick number (1 or 2) and Y indicates the control
number (1 or 2). If the control is not available the replaced value will be “-1”.

{STATE_JOYSTICKXFORCESLIDERY}
- This token is used to indicate the force slider
value. X indicates the stick number (1 or 2) and Y indicates the control number (1 or 2). If
the control is not available the replaced value will be “-1”.

{STATE_JOYSTICKXVELOCITYSLIDERY} - This token is used to indicate the velocity
slider value. X indicates the stick number (1 or 2) and Y indicates the control number (1 or
2). If the control is not available the replaced value will be “-1”.

VoiceAttack Path Tokens

VoiceAttack has a few tokens that can be used in places that require a file path (sound file
locations and application locations). There are certain cases where it is helpful to keep
certain files together, especially when it comes to sharing profiles.

{VA_DIR} - This is the VoiceAttack installation directory.

{VA_SOUNDS} - By default, this is the folder named, 'Sounds' under the VoiceAttack root
directory. This is a place where you can store your VoiceAttack sound packs. If you do not
want to use the 'Sounds' folder in the VoiceAttack installation directory, you can change this
to be whatever folder you want it to be on the VoiceAttack Options page.

{VA_APPS} - This is the folder named, 'Apps' under the VoiceAttack root directory. This is
the place where you can store apps that you use with VoiceAttack (.exe files) and
VoiceAttack plugins (.dll files). Just like the, 'Sounds' folder, you can change the location of
the VoiceAttack Apps folder in the VoiceAttack Options page.

- Updated for v1.5.8.19
« Last Edit: May 31, 2016, 04:13:26 pm by gmagenheimer »

Slan

  • Global Moderator
  • Newbie
  • *****
  • Posts: 29
Re: Text Tokens in VA
« Reply #1 on: November 24, 2016, 03:41:24 am »
Gary is far to adept at adding more stuff all the time.

As the post was just a paraphrase of the help documentation, here's a pointer to the help file on the web:

http://voiceattack.com/VoiceAttackHelp.pdf

The Text-to-speech tokens section starts at page 85 ish.