Home / Publications / Speech Recognition / Two Methods for Triggering Macro Express Scripts with NaturallySpeaking

Two Methods for Triggering Macro Express Scripts with NaturallySpeaking

Copyright © Alan Cantor 2008. All rights reserved.
Presented at the SIG 11 (Computer Applications) Show-and-Tell at RESNA 2008.


I tested two methods for triggering Macro Express scripts via NaturallySpeaking while voice-enabling a complex application as part of a workplace accommodation. The application, which is web-based and runs in Internet Explorer, consists of approximately 30 pages, each page with up to twenty fields and 25 hypertext links. Built-in NaturallySpeaking commands for interacting with form elements do not work reliably or, on many pages, do not work at all due to HTML and JavaScript problems.

The problem

Initial attempts to use the scripting language built into NaturallySpeaking Professional Edition to develop custom commands were promising. But as the scripting project became more complex, two difficulties were encountered:

1. Commands that send more than eight or ten keystrokes execute slowly. (Some of the commands send 30 or more keystrokes.)

2. A NaturallySpeaking 9.x "bug" makes it difficult to script certain commands. To reduce the need to memorize commands, I chose command names that exactly matched field labels. For example, saying "First Name" navigates to the "First Name" field. Although most labels appear only once in the application, 40 appear two or more times. The straightforward way to script commands with identical names is to make them window-specific. The scope (availability) for a command is restricted to the window in which the command is active. Unfortunately, the NaturallySpeaking 9.5 MyCommands Editor prohibits duplicate command names for Internet Explorer windows. Although creating two or more commands that share a name is possible, coding them is not simple.

The workaround to both problems was to script NaturallySpeaking commands that trigger Macro Express scripts. The Macro Express "Text Type" command outputs keystrokes significantly faster than the NaturallySpeaking "SendKeys" command. Furthermore, setting the scope to Internet Explorer windows is straightforward and reliable with Macro Express.

I experimented with two ways for NaturallySpeaking to trigger Macro Express scripts: (1) NaturallySpeaking sends keystrokes to launch a Macro Express hotkey macro; (2) NaturallySpeaking activates a shell command to launch a Macro Express macro. In theory, the first method should execute more quickly, and the second method should be more reliable. In practice, both methods worked equally well.

Code samples

Use NaturallySpeaking Professional edition to trigger a Macro Express script nicknamed "test 1" and activated by Ctrl+Alt+T:

Hotkey method

Sub Main
	' Note: ^ = Control, % = Alt, + = Shift
	SendKeys "^%t"
End Main

Shell command method

Sub Main
	' Note: Use /A switch before Macro Express nickname
	ShellExecute "[macro_express_folder_path]\meproc.exe /Atest 1"
End Main