Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

VS 2012, powershell, and creating a custom menu

$
0
0

Using VS 2012, I'm trying to have some powershell script create a custom menu for me and fire off commands from the click events, but they don't seem to function. I thought I had this working successfully, but upon creating a new VS session and closing my old one, it no longer functions and I can't remember what I'm missing..

Why isn't the click event getting triggered?

$menubar = $dte.CommandBars["MenuBar"]
$cmenu = $menubar.Controls.Add([Microsoft.VisualStudio.CommandBars.MsoControlType]::msoControlPopup, 98765432, "CUSTOM", 38, $false)
$cmenu.Caption = "CUSTOM"
$cmenu.Enabled = $true
$item = $cmenu.Controls.Add([Microsoft.VisualStudio.CommandBars.MsoControlType]::msoControlButton, 987654321, "CUSTOM", 1, $false)
$item.Enabled = $true
$item.Caption = "CUSTOM"
$itemEvents = $dte.Events.CommandBarEvents($item)
$itemEventInterface = Get-Interface $itemEvents ([EnvDTE._dispCommandBarControlEvents_Event])
$itemClickEvent = [EnvDTE._dispCommandBarControlEvents_ClickEventHandler]{ $dte.ExecuteCommand("Help.Samples") }
$itemEventInterface.add_Click($itemClickEvent)

I know the event is working because the Invoke fires correctly -- But I'm missing some registration somewhere I suppose.  Your help would be greatly appreciated

$itemClickEvent.Invoke($menubar, [ref]$true, [ref]$false)


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>