You can add shortcuts to the .vsct file. This file is created automatically in the wizard when creating a new extension and says that it will have a menu command. To add it manually:
- Create MyCommands.vsct
- Set file properties for VSCTCompile
- Unload the project, right-click and edit the project:
:
<VSCTCompile Include="MyCommands.vsct">
<ResourceName>Menus.ctmenu</ResourceName>
<SubType>Designer</SubType>
</VSCTCompile>
:
[ProvideMenuResource("Menus.ctmenu",1)]
public sealed class MyPackage : Package
:
<KeyBindings>
<KeyBinding guid="yourCmdSet" id="cmdAwesome"
editor="guidVSStd97"
key1="VK_F7" mod1="Control Alt"
key2="VK_F1">
</KeyBinding>
</KeyBindings>
:
OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (null != mcs)
{
var menuCommandID = new CommandID(GuidList.yourCmdSet,(int)PkgCmdIDList.cmdAwesome);
var menuItem = new MenuCommand((sender, evt) =>
{
}
}
: