Xona Games' current project: Duality: ZF, an Xbox 360 2D shooter (shoot'em up / shmup).
Home
Contact
About
Forums
 ___
Games:
Duality: ZF
 ___
Articles:
Tech
Windows
Webmaster
Blog
Coding
 ___
Web Utilities:
Domain Hacks
Suggest
 ___
Freeware:
ZoomView
AntiSpam Mailto
 ___
Quotes:
Inspirational
Intelligence
Education
Action
Scientific
Chess
Financial
Programming
 ___
Social Networks:
YouTube
Facebook
 ___
Books
Videos
Wallpapers
 ___
Music
Color List
TI-99/4A
Parsec
Optical Illusions
Web Design
Trivia
Domains
Donations
Copyrights
Disclaimer
Links
 ___
Forums
About
Contact
Visual Studio .NET Keyboard Shortcuts Macro


Tuesday, August 02, 2005
By: Jason Doucette
Printer Friendly Version

This article describes how to create and run a macro, from within Visual Studio .NET, which produces an HTML table showing all of your current keyboard mappings (shortcuts).  It is useful for finding key bindings, and provide a much easier way to merely browse through them, rather than using Visual Studio's ridiculously small browse window (which shows 4 and a half  listings at once).

 

How to Create the Macro

To create this macro, go into Tools menu -> Macros -> Macros IDE...

Within Project Explorer, right-click MyMacros, select Add, select Add Module...

Add a new module named 'KeyboardShortcuts'.

Copy the entire macro source (listed at the bottom of this article), and paste it into the new module.  You will notice the 'Utilities' line within the source code is underlined in blue, indicating an error.

To rectify this, go into the 'Samples' directory inside Project Explorer, and find the 'Utilities' module.  You need to copy this entire 'Utilities' module from the 'Samples' directory into the 'MyMacros' directory, using standard copy and paste operations.  If you do not make a copy of the 'Utilities' module in the 'MyMacros' directory, the code will not be able to reference it.

Build the macro by clicking Debug menu -> Build.  If there are no errors - which is indicated by a lack of any response whatsoever from the IDE <sigh> - then everything is ready.  (If there is an error, the Macro IDE will highlight it, and show the error in the Task List window.)  You can now close the Macro IDE window, as the macro will be run from the main Visual Studio window.

 

How to Run the Macro

Go to Tools menu -> Macros -> Macro Explorer.

Under 'MyMacros', under the 'KeyboardShortcuts' directory, a new macro called 'ListKeyboardShortcuts' will be available.

To run the macro, double click it.  If you wish to see the macro's progress as it runs, make sure the Output window is open before you start it.  The macro will take approximately 30 seconds to run.  Once it is complete, copy the entire text of the Output window, and paste it into an HTML file.  Sample macro output is shown within the pages linked below.

 

Macro Source

Imports EnvDTE Imports System.Diagnostics Public Module KeyboardShortcuts Sub ListKeyboardShortcuts() Dim i As Integer Dim j As Integer Dim pane As OutputWindowPane = Utilities.GetOutputWindowPane("Commands") Dim keys As System.Array pane.Clear() pane.OutputString("<font face=arial>") pane.OutputString("<table border=1 cellspacing=0 cellpadding=2 bgcolor=f0f0ff>" + Chr(10)) pane.OutputString("<tr><th colspan=2 bgcolor=d0d0e0>Keyboard Mappings</th></tr>" + Chr(10)) pane.OutputString("<tr><th bgcolor=e0e0f0>Action</th>") pane.OutputString("<th bgcolor=e0e0f0>Key</th></tr>" + Chr(10)) For i = 1 To DTE.Commands.Count keys = DTE.Commands.Item(i).Bindings If keys.Length > 0 Then pane.OutputString("<tr>") 'DTE.Commands.Item(i).Name() is sometimes blank. 'We will print an m-dash in this case, as printing a blank table cell is visually 'misleading, as such a cell has no borders, making it appear to be attached to 'another cell. If DTE.Commands.Item(i).Name() <> "" Then pane.OutputString("<td valign=top>" + DTE.Commands.Item(i).Name()) Else pane.OutputString("<td><center>&mdash;</center>") End If pane.OutputString("</td><td>") For j = 0 To keys.Length - 1 If j > 0 Then pane.OutputString("<br/>") End If pane.OutputString(keys(j)) Next pane.OutputString("</td></tr>" + Chr(10)) End If Next pane.OutputString("</table></font>") End Sub End Module

 

Credit

The macro originated from a 'Lance' on the Visual Studio Core Team. William Garrison found this macro on the microsoft.public.vsnet.ide newsgroup, and modified it to improve its output. I found his modifications on William's website and further modified it to clear the confusion of blank cells.

 

Sample Macro Output

I have run the macro from within Visual C++ .NET 2003 (v7.1), with the Keyboard Mapping Scheme set to emulate all of the possible pre-set settings. You can set it yourself by going to: Tools menu -> Options -> Environment -> Keyboard -> Keyboard Mapping Scheme. I should note that while these Keyboard Mapping Scheme settings are supposed to exactly replicate the keyboard mappings of different versions of Visual Studio, it is known to be somewhat inaccurate. I recall only one such incident, and there may be more: One of the mapping schemes did not provide a particular shortcut that an author was accustomed to. Searching the above macro's output proved that the shortcut was not only missing, but did not exist at all.

Here are the five Keyboard Mapping Schemes that come with Visual C++ .NET 2003 (v7.1):

 

Discuss.

 

By: Jason Doucette
(Interested in Writing Articles For Xona.com?)



> Home
> Discuss
> Contact
  ©Xona.com™


Email:
Xona.com™ and Xona Games™ (formerly Xonatech™ & Saw Tooth Distortion™)
2,672,561 page views (since 2004-Jul-27)

Free Ringtones | Mobile Phones | Loans | Cell Phones | Credit Card Debt Consolidation