let me add custom menu items which run "command window" commands

Locked let me add custom menu items which run "command window" commands

  • Thursday, August 30, 2012 5:54 PM
     
     

    Because I work from different locations (office, laptop, home), I need to be able to quickly switch between Visual Studio window layouts.

    In VS2010, I was easily able to accomplish this by creating a custom menu item that ran a macro to import my desired saved window layout settings files.

    In VS2012, macros are entirely gone, so I'm not able to do this.

    I got my hopes up when I realized that the VS "Command Window" lets me invoke the same commands, but was very disappointed to find that I wasn't able to create custom menu items for these commands if arguments were required.

    Bottom line: I want to create a menu item and shortcut key for a command like this:
      Tools.ImportandExportSettings /import:"C:\Users\robs\My Documents\Visual Studio 2012\Settings\WindowLayout-Multi.vssettings"

    Currently, the only way to do this seems to be to write an extension using the VS SDK - this is WAY more work than it should be.

    Am I missing something?

All Replies

  • Thursday, August 30, 2012 5:59 PM
    Moderator
     
     

    No.  Macros are no longer supported.  The supported solution is to create an extension to VS.  Extensions are really easy to write (compared to the old addin model) and can do everything macros could do, in a .NET language of your choosing and is easily installable on other machines. 

    Alternatively there has been a window layout extension floating around for years that might have been updated for VS2012 already.  I haven't looked myself.

    Michael Taylor - 8/30/2012
    http://msmvps.com/blogs/p3net

  • Thursday, August 30, 2012 8:26 PM
     
     

    Thanks Michael,

    I actually did solve the issue by writing a VS extension, however it is definitely not something that I would consider "easy".

    It's not a problem for me that macros are no longer supported, since the VS Command Window offers pretty much the exact same functionality.  The only thing missing is that I can't hook up "Command Window" commands to menu/toolbar items.

  • Friday, August 31, 2012 8:22 PM
    Moderator
     
     Answered

    Now that I've had time to think about it some more I have thought of an easier approach that works in VS2012 and previous versions, command aliasing.   You can define an alias that executes the command you want and then just type it in from the command window (or immediate window in CMD mode).  Here's the documentation on how to define aliases: http://msdn.microsoft.com/en-us/library/xasxzd71.aspx

    Michael Taylor - 8/31/2012
    http://msmvps.com/blogs/p3net

     
  • Tuesday, September 04, 2012 12:49 PM
     
     
    Now we're talking - thanks!