Quantcast
Channel: Developer Express Inc.
Viewing all articles
Browse latest Browse all 2370

Voice Commands in CodeRush for Visual Studio

$
0
0
Voice Commands let you control and access Visual Studio by voice. Voice Commands are fully customizable, are context-aware, and support inferred intent (e.g. a “Build Solution” voice command can be triggered with the phrase “please compile all my projects”.
To invoke a Voice Command, hold down the left Ctrl key and say the command. Make sure you've set up voice features first. 
Release the Ctrl key when you have finished.

Also available:

Opening Files

The most important Voice Command for developers working in large solutions is the Open fileName command. This command allows you to open any file in your solution. Just hold down the left Ctrl key and say “Open” followed by only the file name (the file extension is unnecessary if the file uses the default extension for the project). This feature is a huge productivity boost when working in very large solutions (e.g., more than 10,000 files). It is the fastest/easiest way to open files (much faster than using a mouse or keyboard). It even works if you only remember a portion of the camel case file name parts (or if you say the parts slightly out of order).
For example, if my solution contains a file named StreamDeckStorageServices.cs, I can open that file with any of these spoken phrases:
  • "open stream decks storage"
  • "open streaming deck service"
  • "open deck storage service"

Showing Tool Windows

The second most important Voice Command to learn is the Show Me toolWindowName command. Just hold down the left Ctrl key and say “Show me” followed by the name/title of the Visual Studio tool window (Microsoft ships about 100 different ones with Visual Studio). This will open the selected tool window in Visual Studio. Here are some examples:
  • "show me Call Stack"
  • "show me Locals"
  • "show me Watch 3"
  • "show me Parallel Watch 2"
  • "show me Immediate"
  • "show me Solution Explorer"
  • "show me Properties"
  • "show me Threads"
  • "show me Modules"

Navigating Types and Members

To jump to any member in the active class, say "member" followed by the name of the member.

To jump to any type in the solution, say "type" followed by the name of the type.

Bookmarks

You can drop a permanent named bookmark anywhere in the code and return to it laters by voice. To drop a bookmark, hold down the left Ctrl key and say “Bookmark” followed by the name of the bookmark. For example:

"bookmark storage"

Later, to return to that bookmark, hold down the left Ctrl key and say “Go to” followed by the same name of the bookmark. For example:

"go to storage"

Other Voice Commands

Voice Commands make accessing files and tool windows easy. They are also great for commands you may execute irregularly for which you don’t already have memorized shortcuts. Some examples of prebuilt Voice Commands shipping in CodeRush:
  • "copy file path" - copies the full path of the active file to the clipboard.
  • "open containing folder" (or "file location") - opens the folder containing the active document in a new instance of Windows Explorer.
  • "new folder" - adds a new folder to the project (in the same folder containing the active document).
  • "add class" - adds a new item to the project
  • "add existing item" - adds an existing item to the project
  • "project properties" - opens the properties window for the active project 
  • "filter solution explorer" - activates the Solution Explorer's search filter TextBox (you can then hold down the right Ctrl key a say the filter you want to use)
  • "repeat last test run" - repeats the last test run in the last mode it was run under (e.g., debug or normal)
  • "run this" - runs the active test case (or runs all the test cases in the active test class)
  • "debug this" - debugs the active test case
  • "implementations" navigates to implementations of the active interface member
  • "full screen" toggles full screen mode
  • "NuGet packages" - brings up the NuGet package manager for the solution
  • "show me CodeRush test runner" - brings up the CodeRush Test Runner tool window
  • "DevExpress" - opens up the devexpress.com web site.
Just hold down the left Ctrl key and say any of the commands above (many of these commands also support inferred intent, so you don’t need to be precise when you say them).

Custom Voice Commands

You can create your own voice commands on the CodeRush Voice Commands options page. You can also edit/delete/enable/disable existing voice commands on this page. 

You can get to this page quickly from the CodeRush | Voice Commands... menu item (this options page is in the IDE/Cognitive options folder).

Creating a New Folder for Your Voice Commands

Take a moment to consider what folder will contain your new command. While you can select one of the existing folders, for reasons based on versioning, updating, and sharing we recommend creating a new folder to hold your commands. To create a new folder, click the New Folder icon at the top:

Enter a folder name, and check the "Make this a top level folder" checkbox.

Click OK.

Adding a New Voice Command

Click the New Voice Command button at the top left.

An empty Voice Command is added to the active folder. The voice command contains the following fields/options:

First, decide the words you want to say to execute the command. For this example, we'll create a new Voice Command that applies code changes during debugging (invoking the Visual Studio command "Debug.ApplyCodeChanges"). In this case we might want to trigger this command with two different phrases:

  • "apply code changes"
  • "hot reload"

For the words to say, we can use a pipe symbol to separate equivalent alternatives. So in this field we could enter "apply code changes | hot reload"​.

If you have supplied an OpenAI API key, you may want to check the "Allow Semantic Equivalents" checkbox. In this example, it would allow you to invoke the command by saying "let's apply these awesome code changes" or "it's time to reload at super high temperature". This means you won't have to recall the specific words of the command - just the essence of what you want to do. Checking this checkbox will send any spoken phrase that is not perfectly matched to OpenAI to get the inferred match. 

Choose the command to bind to this new Voice Command. The combobox on this page lists all CodeRush commands. If you want to bind to a Visual Studio command (like “Edit.Copy”), simply enter it here. You can find a complete list of Visual Studio commands in the Visual Studio Options dialog on the Keyboard & Shortcuts page. For our example, let's enter Debug.ApplyCodeChanges. 

You can leave the Parameters textbox empty (some CodeRush commands can take additional parameters).

The last option for our Voice Command is Context, which lets you determine when this voice command is available. Specifying context is generally a good idea because it can improve performance, increase accuracy, and shorten the prompt sent to OpenAI when Allow Semantic Equivalents is turned on. For this example command, it only makes sense to invoke it when actively debugging. To add a context, click the "..." button to the right of the Context TextBox. The Select Context Provider dialog will appear.

In the filter dialog at the top, enter "Debug" and click the System\DebugMode context. This context is true when you are debugging in Visual Studio:

The filled-out fields for this example command should now look like this:
If you've been following along with this example so far, click OK and try it out! Start a debugging session, enter a breakpoint, change some code, hold down the left Ctrl key and state your command! Look to the status bar for confirmation that code changes have been applied. Congratulations! You have just created your first Voice Command!
More Voice Features
This release contains powerful features that support voice interaction in Visual Studio. Other posts documenting voice features in CodeRush:


Viewing all articles
Browse latest Browse all 2370

Trending Articles