Tuesday, May 3, 2011

Calling Visual Studio 2005 external tool without changing focus

While editing a file I want to use a hotkey to call an External Tool that I have setup to use the "Output" tab. Currently when I use the hotkey the focus leaves the edit pane and goes to the "Output" window - I want the focus to not change from the edit pane.

From stackoverflow
  • Try assigning a macro to your hotkey and executing the external tool from the macro. You can create a new macro using the Macro Editor by pressing Alt-F11.

    Brandon Leiran : Unfortunately using a macro to call the external tool still switches focus to the "Output" tab. Thanks for making me aware of Visual Studio macros though.
  • Using a Visual Studio macro (inspiration from Stephen Nutt) an acceptable (to me) workaround is:

    Public Module RunTestExternalTool
        Sub RunExternalTool1andReturnFocusToEdit()
            DTE.ExecuteCommand("Tools.ExternalCommand1")
            DTE.ExecuteCommand("View.ViewCode")
        End Sub
    End Module
    

    This makes an assumption that the user wants to return focus the the ViewCode pane (no matter where they started).

0 comments:

Post a Comment