Custom Scripting Macros for Dragon NaturallySpeaking

Dragon NaturallySpeaking Professional 9 offers a robust scripting interface with four discrete tools:

Extensive help files support the scripting tools and, the tutorial file, available in the NaturallySpeaking Help Menu, "Working in Applications and Advanced Topics," provides additional support for these tools. In addition the Help topics supporting scripting are available from the Help control located in the New Command Wizard.

NGT, Inc. also offers a definitive manual for writing scripts in Dragon NaturallySpeaking. Written by Larry Allen, it's available both in print and electronic format.

Text and Graphic Macro Writing

To write a Global Text macro. Say, "Create new command," or use DNS Tools/Add New Command menu. The new command wizard will deploy.

  1. Write a command phrase to launch the Text macro. It should be two or three words and not sound like a common phrase to prevent unintended launches.
  2. Enter text content to be deployed when the command phrase is recognized.
  3. Checking the Plain Text checkbox will allow the Text macro to take on the target attributes when launched (ie., if an MS Word document is Times New Roman 10 the text will appear in that font and size).
  4. Click the Save Control.

A screenshot of the MyCommands Editor in Text and Graphics mode. Highlighted numbers show where the user should input information.

Step-By-Step Macro Writing

To write a Step-By-Step macro. Say, "Create new command," or use DNS Tools/Add New Command menu. The new command wizard will deploy.

Match Destination Formatting

To write a macro to use the "Match Destination Formatting" tool in Microsoft Word create a command using the Step-by-Step keystroke tool:

  1. Put in the command name "Match Destination Formatting"
  2. Change the Command Type to Step-by-Step
  3. By default the New Step control will show Keystrokes. Click the Insert control or use Alt+R to activate. This will deploy a simple key capture window. Press the keys Alt+Shift+F10 (the hot key associated with activating a Smart Tag). Activate the Okay control. Reactivate the Insert control and press the "D" key on the keyboard, followed by the Okay control.
  4. Use the Save control.

A screenshot of the MyCommands Editor in Step-by-Step mode. Highlighted numbers show where the user should input information.

When a Smart Tag appears the command Match Destination Formatting? will complete the execution of this function in the Smart Tag.

Go to Work Orders

The following step-by-step script can be used in Outlook 2003 to put focus on a specific folder. It can also be written as a variable macro which would allow the use of a list to reference the specific folder name.

  1. With the MyCommands Editor in Step-by-Step mode, type in, "Go To Work Orders" in the MyCommand Name field.
  2. Into the Steps field type or cut and paste the following:
    
    Send Keys "^y"
    Send Keys "%f"
    Type "WORKORDERS"
    Wait 50 milliseconds
    Send Keys "{Enter}"
    
    
  3. Press the save button to save your command and close the editor.

A screenshot of the MyCommands Editor in Step-by-Step mode. Highlighted numbers indicate where the user should input information.

Advanced Scripting Macros

The first Advanced Scripting macro comes from the examples available in the DNS Pro Command Browser.

A screenshot of the MyCommands Editor in Advanced Scripting mode.


' This command shows how to refer to variables. If you
' say, for example, "sample script three elephants" it
' types the word "elephant" three times.

' 1to10 is an existing variable used in many built-in
' commands. samplelist is a variable created just
' for this command.

' UtilityProvider.ContextValue(0) contains the value
' spoken in place of 1to10.
' UtilityProvider.ContextValue(1) contains the value
' spoken in place of samplelist.


Option Explicit
Dim i As Integer
Dim j As Integer

Sub Main
        j = str2int(UtilityProvider.ContextValue (0))
        For i = 1 To j
                SendDragonKeys " " + UtilityProvider.ContextValue(1)
                SendDragonKeys "{Backspace}"  'to remove the s
        Next i
End Sub
Function str2int (num As String )
        Select Case num
                Case "one"
                        str2int = 1
                Case "two"
                        str2int = 2
                Case "three"
                        str2int = 3
                Case "four"
                        str2int = 4
                Case "five"
                        str2int = 5
                Case "six"
                        str2int = 6
                Case "seven"
                        str2int = 7
                Case "eight"
                        str2int = 8
                Case "nine"
                        str2int = 9
                Case "ten"
                        str2int = 10
        End Select
End Function

Outlook Calendar Macro

This is an example of advanced scripting using a double variable that would allow the user to put in both month and date with a single command to search through the calendaring system in Microsoft Outlook. It allows voice activated date dictation in the Outlook Calendar view.

Type or cut and paste the following into the Script field of the MyCommand Editor in Advanced Scripting mode:


Sub Main
        SendDragonKeys"{Ctrl+g}"
        If ListVar1= "January" Then SendDragonKeys"01/"
        If ListVar1= "February" Then SendDragonKeys"02/"
        If ListVar1= "March" Then SendDragonKeys"03/"
        If ListVar1= "April" Then SendDragonKeys"04/"
        If ListVar1= "May" Then SendDragonKeys"05/"
        If ListVar1= "June" Then SendDragonKeys"06/"
        If ListVar1= "July" Then SendDragonKeys"07/"
        If ListVar1= "August" Then SendDragonKeys"08/"
        If ListVar1= "September" Then SendDragonKeys"09/"
        If ListVar1= "October" Then SendDragonKeys"10/"
        If ListVar1= "November" Then SendDragonKeys"11/"
        If ListVar1= "December" Then SendDragonKeys"12/"
        SendDragonKeys"{" & ListVar2 & "}"
        SendDragonKeys"{Enter}"
End Sub


Copyright 1999- 2010 Next Generation Technologies Incorporated

Jump to: site navigation | page content

Highlighted Products and Services

Site Navigation