Skip to content

Instantly share code, notes, and snippets.

@swwwolf
Last active October 29, 2016 13:15
Show Gist options
  • Save swwwolf/c80cac88a821d8e5df36 to your computer and use it in GitHub Desktop.
Save swwwolf/c80cac88a821d8e5df36 to your computer and use it in GitHub Desktop.
Invoking external tool from the Visual Commander
using EnvDTE;
using EnvDTE80;
public class E : VisualCommanderExt.IExtension
{
public void SetSite(EnvDTE80.DTE2 DTE_, Microsoft.VisualStudio.Shell.Package package)
{
DTE = DTE_;
events = DTE.Events;
documentEvents = events.DocumentEvents;
documentEvents.DocumentSaved += OnDocumentSaved;
}
public void Close()
{
documentEvents.DocumentSaved -= OnDocumentSaved;
}
private void OnDocumentSaved(EnvDTE.Document doc)
{
if(doc.Language == "C/C++")
DTE.ExecuteCommand("Tools.ExternalCommand1");
}
private EnvDTE80.DTE2 DTE;
private EnvDTE.Events events;
private EnvDTE.DocumentEvents documentEvents;
}
@fut33v
Copy link

fut33v commented Oct 26, 2016

It will be great to add in OnDocumentSaved method this lines

var currentDocument = DTE.ActiveDocument;
currentDocument.Activate();

for focusing back on document instead of output window (I'm too lazy to push F7 after my every Ctrl+S)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment