问题描述:

How do I subscribe to a 3rdparty extension's command from my own VSIX extension? Such as OnClick event of an extension.

网友答案:

If it is a command, you should be able to capture it using DTE.Events.CommandEvents[commandGuid, commandId].BeforeExecute (or AfterExecute). (MSDN)

If you do not know the ID and GUID you can subscribe to all commands (as both indexer parameters are optional), add logging of ID/GUID, then use the command you are interested in.

Important Note:
I believe you have to keep a reference to DTE.Events.CommandEvents[commandGuid, commandId] somewhere so it will not be garbage collected. Otherwise you may lose your subscription.

相关阅读:
Top