In my package I register commands in the following way:
var mcs = _provider.GetService(typeof (IMenuCommandService)) as OleMenuCommandService;
var commandId= new CommandID(myCommandGroup, myCommandId);
_command = new OleMenuCommand(MyAction, commandId);
mcs.AddCommand(_command);
Next, when I want to check what commands are registered in Visual Studio, I'm able to do it using following code:
var dte = (DTE) _provider.GetService(typeof(SDTE));
var commands = dte.Commands.Cast<Command>();
foreach (var command in commands.OrderBy(c => c.Name))
{
var message = command.ID + "(" + command.Name + "): ";
foreach (object b in command.Bindings)
{
message += b.ToString();
}
Log.Instance.AppendLine(message);
}
I can identify mine, because there is key shortcut binded to it, e.g.
1055(Analyze.NavigateForward): Global::Shift+Alt+4
8194(Analyze.NewPerformanceSession):
...
256(): Global::Ctrl+R, Ctrl+H // my command, empty brackets - no name defined
Unfortunately, its name is empty. How to associate name with the command?
UPDATE (of what I have in *.vsct file):
<Buttons>
<Button guid="myCommandGroup" id="myCommandId" type="Button">
<CommandFlag>DontCache</CommandFlag>
...
<Strings>
<CanonicalName>MyCommand</CanonicalName>
<CommandName>MyCommand</CommandName>
<ButtonText>MyCommand</ButtonText>
</Strings>
</Button>
</Buttons>
...
<KeyBindings>
<KeyBinding guid="myCommandGroup" id="myCommandId" editor="guidVSStd97"
mod1="Control" mod2="Control" key1="R" key2="H" />
</KeyBindings>