Skip to content

Instantly share code, notes, and snippets.

@jackfoxy
Created July 23, 2016 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackfoxy/5c537297c86657aba4e8defe9a786eeb to your computer and use it in GitHub Desktop.
Save jackfoxy/5c537297c86657aba4e8defe9a786eeb to your computer and use it in GitHub Desktop.
Visual Studio Macro learnings and questions
/// <reference path="C:\Users\Jack\AppData\Local\Microsoft\VisualStudio\14.0\Macros\dte.js" />
// Blog announcing new VS macro facility:
// https://blogs.msdn.microsoft.com/visualstudio/2016/05/11/macros-extension-open-sourced-in-visual-studio-2015
//
// Macros get saved to:
// <user>\AppData\Local\Microsoft\VisualStudio\14.0\Macros\Macros
// does not seem to be any way to change default folder. Roaming may also work, but I have not experimented with that.
//
// Tne open source project:
// https://github.com/Microsoft/VS-Macros
// Some additional documentation in the readme.
// From the "Caveats":
// "Recording interaction with dialogs [not supported]"
// However the doc is silent about tips for programaticaly interacting with dialogs by editing the generated javascript. (See my numbered "wants" below.)
//
// Additional docs are here:
// https://msdn.microsoft.com/en-us/library/envdte._dte_properties.aspx
// Some code examples in VB, but they do not include which DLL to load or the using statement opening the EnvDTE namespace.
// I tried referencing this DLL
// C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\cgbueo4f.jug\EnvDTE.dll
// but was not able to get F# code to replicate the object interactions in the VB example.
try {
dte.ExecuteCommand("File.NewProject");
// this really just opens the new project dialog to the last template you loaded
// 1) Want to know how to automate walking through dialog to intended template (F# console app)
dte.ExecuteCommand("Edit.SelectAll");
dte.ActiveDocument.Selection.Delete();
dte.ExecuteCommand("Edit.InsertSnippet");
// this pops up the insert snippet context menu'
// 2) Want to know how to walk down menu and select intended snippet
// then I can add:
// dte.ExecuteCommand("File.SaveAll");
}
catch (_) {
//catch so cancelling doesn't pop-up a notification
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment