Vocola Information Pages   by Rick Mohr   (last modified February 18, 2002)

 Introduction
 Using Vocola
 Language Tutorial
    Keystroke Commands
    Using Alternatives
    Defining Variables
    Substituting Actions
    Function Calls
    Optional Words
    Comments
->     Contextual Commands
    Example File
 Download Vocola
 Install Vocola
 Converting DVC Files
 Troubleshooting
 Support
 Wish List
 My RSI Story
 

Contextual Commands

Vocola Tutorial: Enable by Context

We've discussed how to create "global" commands (which are always enabled) as well as application-specific commands (which are enabled only when a particular application is active). In addition, you can create contextual commands, which are enabled only when a particular window has the focus.

By specifying all or part of the window title in a context statement you can create commands specific to that window. For example, here are three groups of commands for Microsoft Outlook (from the application-specific command file "outlook.vcl"): 

 Microsoft Outlook:
   New Message = {Ctrl+n};
   Reply to Message = {Ctrl+r};
   Reply to All = {Ctrl+Shift+r};
   Forward Message = {Ctrl+f};

 Message (Plain Text):
   Send That = {Alt+s};
   Reply Here = "{Home}{Shift+End}{Del}{Enter 3}{Left 2}";

 Calendar:
   View Month = {Alt+m};
   View Work Week = {Alt+r};

The context statement "Microsoft Outlook:" specifies that subsequent commands should be active only when "Microsoft Outlook" is part of the title of the active window. When reading mail using Outlook the main window title is "Inbox - Microsoft Outlook", so the first group of commands above (to create, reply to, or forward a message) will be enabled.

Similarly, when editing a mail message the window title is "Message (Plain Text)", so the second group of commands above will be enabled. Finally, the third group of commands above will be enabled when the Outlook calendar is displayed.

Here is another example. The text editor application Emacs can be customized so that the window title includes the name of the currently-edited file. For example, when editing iexplore.vcl (the file of Vocola commands for Internet Explorer) the Emacs window title is "Emacs - iexplore.vcl - 01.05.02". This allows defining a set of contextual commands for editing Vocola files. The application-specific command file "emacs.vcl" would include:

 ### Editing Vocola files
 .vcl:
   Insert Control Key = {Ctrl+;
   Insert Alt Key = {Alt+;
   Save and Load = {Ctrl+x}{Ctrl+s} HeardWord(Load, Voice, Commands);

 ### Editing Perl files
 .pl:
   Insert Hash Reference = ->{}{Ctrl+b};
   New Statement = {Ctrl+e}{Ctrl+j};
   New Statement Above = {Ctrl+a}{Ctrl+b}{Ctrl+j};
   Statement (Start="" | Down={Ctrl+n} | Up={Ctrl+p}) = $1 {Ctrl+a}{Ctrl+i};

So for example when the Emacs window title contains ".vcl", saying "Save and Load" will save the current file and invoke the "Load Voice Commands" command. (This allows quick loading of commands you have created).

Similarly, the second group of commands above is active only when editing Perl files.

Contextual commands don't need to be application-specific. You can also create global contextual commands, as in this example from the global command file "_vocola.vcl":

 Open:
   Go Up = ..{Enter};
   Folder List = "{Shift+Tab 2}{Down}{PgUp}";

This defines two commands for use in a "File Open" dialog box, regardless of the current application. Whenever the window title includes the word "Open", you can say "Go Up" to move to the parent folder.


This page is (c) Copyright 2002 by Rick Mohr, and was last modified on February 18, 2002.