Vocola Information Pages by Rick Mohr (last modified February 18, 2002) |
Contextual CommandsWe'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"):
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:
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":
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. |