Script Editor
Contents
1. Script Editor Overview
2. Editing Features
3. Syntax Highlighting
4. Command Wizard
5. Template Wizard
6. Syntax Validation
7. Breakpoints
8. Custom Popup Menus
9. Execution Tracing
10. Execute Selection
11. Step by Step Execution
1. Script Editor Overview
Script editor provides capability to:
2. Editing Features
VNCRobot editor provides editing
capabilities common in other text editors:
The editor saves all documents in the UTF-8 encoding. Note that though
you should be able to save a text file with any multibyte text, VNCRobot
cannot send characters out of ISO 8859-1 to VNC server. It means that
you can use national characters of most Western Europe languages
(German, Spanish, French, ...) but not Asian, Arabic, East Europian etc.
This is a limitation of the RFB protocol.
3. Syntax Highlighting
VNCRobot v1.3 introduces a rich text editor able to highlight the
script syntax. Elements of the commands are parsed automatically and
they are displayed with configured attributes, i.e. font type and
background/foreground color. To configure the editor style open the Preferences window and navigate to the
Appearance & Accessibility->Script Editor tree node:

4. Command Wizard
VNCRobot editor has a new
command wizard which allows to select commands comfortably from a list
instead of typing them manually. The wizard can be activated by pressing
Ctrl+Enter in the editor. When invoked on an empty line, it displays a
list of available commands as is shown on the picture below. Commands
can be also activated by shortcut keys as is visible in the list below.

If you type a part of a command and open the wizard, it will match the
text against the list and display just applicable commands. If you e.g.
type 'ty' and press Ctrl+Enter, the wizard will display just the Type
and Typeline commands. This happens also when the wizard list is
displayed. If the text you typed is sufficient to identify the command,
it is inserted automatically into the script without displaying the
list. Try to type e.g. 'scr' and press Ctrl+Enter to insert a Screenshot
command into the script.
Pressing of Ctrl+Enter in a line which already contains a valid command
displays a list of supported command parameters. An example of the Connect
command parameters is shown on the picture below. If you select on in
the list, it will be inserted at the end of the line together with a
hint on what the parameter value should be like. Note that the wizard
does not validate the command in any way and it also doesn't check which
parameters the line already contains.

To modify the shortcut key (Ctrl+Enter) open the Preferences window and navigate to
Appearance & Accessibility -> Script Editor.
5. Template Wizard
Code templates are predefined pieces of code. To insert a code template
press Ctrl+I or select "Insert a Template" in the Command Wizard.

For example, to open the Windows Explorer one usually presses Windows+e
on the keyboard and waits until the explorer opens. To insert such an
action into your automated test script you can simply select the
template highlighted in the list above.
Each code template has a short key which allows quicker selection. To
insert the Windows Explorer template without displaying the wizard type
'winexp' into a new line of your editor and press Ctrl+I.
To modify the shortcut key (Ctrl+I) open the Preferences
window and navigate to Appearance & Accessibility -> Script
Editor.
The Template Wizard was introduced in VNCRobot 1.3.1. Note that the
template list is currently fixed and can't be customized. A GUI to edit
the list will be provided in one of the next 1.3.x releases.
6. Syntax Validation
Script editor is capable of validating syntax of your test script. It
means that it checks whether your commands have correct syntax and
highlights the incorrect commands as is shown on the following picture.
If you place your mouse pointer above the invalid line, a tool tip
message with the error description should appear.

To configure color of the highlight open the Preferences
window and navigate to the Appearance->Script Editor tree node.
There are two points when validation is performed:
- Automatic Script Validation
- Pre-execution Validation
Automatic Validation
Whenever you modify a script, automatic validation is run after a
certain period of idle time. This might cause delays by large scripts.
To enable or disable this feature and configure the timeout open the Preferences window and navigate to the
Scripting tree node. This feature is by default on.
Pre-execution Validation
When you select Run or Run Selection to execute a script or its
part, a validation is performed. If there are errors, a warning message
gets displayed. There are options to execute the script anyway (Yes) and
to cancel the execution (No):
- If you select Yes, the script gets executed and all invalid
commands will be skipped.
- If you select No, a message pane with the list of errors gets
displayed at the bottom of the VNCRobot window. Select an error in the
message pane to navigate to the incorrect command line.
7. Breakpoints
Breakpoints let you stop execution of a script on certain lines. Once a
breakpoint is reached, the script gets paused and won't resume until you
deselect the Pause menu item or toolbar button.
To define a breakpoint, click onto the grey column on the left side of
the script editor. The command line turns red and a red globe icon gets
displayed in the column. Eventually left click on the column to open the
breakpoint popup menu and select Add Breakpoint. You can remove
breakpoints in a similar way. The menu also provides a way to remove all
breakpoints in the editor. See the following picture which shows
activated popup menu for an already existing breakpoint.

To configure breakpoint color open the Preferences
window and navigate to the Appearance & Accessibility->Script
Editor tree node.
8. Custom Popup Menus
Script editors provide a way to customize the editor popup menu. This
is often used by commads to provide quick access to command features,
help and configuration. To open a custom popup menu for a command right
click onto the command in the editor. The following picture shows a
custom popup menu for the Press command which includes:
- Display Supported Keys opens the Key
Browser window and lists all key names supported by this command,
- Configure Press opens the Preferences
window with the Press configuration,
- Help on Press opens the Help window with the Press command specification,
- Configure Editor opens
the Preferences window with the Script
Editor configuration.

Popup menus may also contain dynamic items which are available only
under specific conditions. If you for example execute a Wait command or Waitfor together with the timeout
parameter, the menu contains an item labeled Continue which lets
you to bypass the timeout and resume the execution immediately.
The menu can be also activated by pressing Ctrl+Shift+Enter. To modify
this shortcut key open the Preferences
window and navigate to Appearance & Accessibility -> Script
Editor.
9. Execution Tracing
When a script is being executed, VNCRobot switches among editors and
scrolls the editor view to show the executed line. This feature enables
user to see the execution progress and currently executed command. The
following picture shows an example of an executed line.

This feature can be controlled by two flags:
- Open Included Files During Script Execution flag available
in Preferences under the Scripting tree
node. When you execute a script, it might run or include other scripts
using the Run or Include commands. This
flag defines whether VNCRobot should open these nested scripts in a new
editor when they get executed.
- Follow Execution Trace menu
item and toolbar button. If the item/button is selected, VNCRobot
will switch among editors and scroll the editor view to show the
executed line. This flag is by default switched on when you start a
script execution. If you switch among editor manually or start to edit a
script during execution, this feature gets automatically switched off.
To configure color of the executed line open the Preferences window and navigate to the
Appearance->Script Editor tree node.
10. Execute Selection
If you want to execute just a part of your script, you may select
(highlight) the lines you want to execute and select the Execute Selection menu item to
start the execution. Note that the commands do not have to be
highlighted completely. Even if you select just a single character in
the command, VNCRobot executes the whole line. The following picture
shows execution of two selected command lines.

Note two important features of partial executions.
- First, even if you run just a few selected commands, all
procedures and variables contained in the script will be correctly
defined and they may be referenced in the selected commands.
- Second, execution of commands nested in a procedure is not
allowed. If you select part of a script which contains a procedure, all
commands in the procedure body will be skipped. You can however call
that procedure.
11. Step By Step Execution
There's a Step By Step Execution menu item
and toolbar button which allows you to execute just one line of code at
a time. The following rules apply:
- When the Step By Step feature is on, the execution gets paused on
every line and you have to unpause to proceed to the next line.
- If the script line contains a command which involves execution of
other commands located in a different file, the behavior depends on two
flags, Open Included Files During Script Execution flag
(configurable via Preferences->Scripting) and the Follow
Execution Trace menu item and
toolbar button. This applies mainly to procedure calls and command Run:
- If both flags are on, the filegets opened in an editor and the
involved commands are also executed step by step.
- If at least one of the flags is off, the command gets executed
in one shot, e.g. the whole procedure or file is executed at once.