ISEMenuItemCollection 对象是 ISEMenuItem 对象的集合。 它是 Microsoft.PowerShell.Host.ISE.ISEMenuItemCollection 类的实例。 例如,$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus
对象用于自定义 Windows PowerShell® 集成脚本环境(ISE)中的 加载项 菜单。
方法
Add(string DisplayName, System.Management.Automation.ScriptBlock Action, System.Windows.Input.KeyGesture 快捷方式)
在 Windows PowerShell ISE 2.0 及更高版本中受支持。
将菜单项添加到集合。
DisplayName 要添加的菜单的显示名称。
Action 指定与此菜单项关联的作的 System.Management.Automation.ScriptBlock 对象。
快捷方式作的键盘快捷方式。
返回刚刚添加的 ISEMenuItem 对象。
# Create an Add-ons menu with a fast access key and a shortcut.
# Note the use of "_" as opposed to the "&" for mapping to the fast access key letter for the menu item.
$menuAdded = $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add('_Process', {Get-Process}, 'Alt+P')
Clear()
在 Windows PowerShell ISE 2.0 及更高版本中受支持。
从菜单项中删除所有子菜单。
# Remove all custom submenu items from the AddOns menu
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Clear()
另请参阅
- ISEMenuItem 对象
- Windows PowerShell ISE 脚本对象模型的 用途
- ISE 对象模型层次结构