Search code examples
c#visual-studioenvdtevspackage

Activate Visual Studio's Output window using DTE


I've created a custom output window pane for my VSPackage:

Output window and tabs in Visual Studio 2013

Using this code:

// Creating Output Window for our package.
IVsOutputWindow output = GetService(typeof(SVsOutputWindow)) as IVsOutputWindow;
Guid guildGeneral = Microsoft.VisualStudio.VSConstants.OutputWindowPaneGuid.GeneralPane_guid;
int hr = output.CreatePane(guildGeneral, "Codex", 1, 0);
hr = output.GetPane(guildGeneral, out ApplicationConstants.pane);

ApplicationConstants.pane.Activate();

QUESTION

How can I select the Output tab when other tabs are currently selected?


Solution

  • To activate (focus) on Visual Studio's Output window:

    DTE dte = (DTE)GetService(typeof(DTE));
    Window window = dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
    window.Activate();