Um objeto ISEMenuItem é uma instância da classe Microsoft.PowerShell.Host.ISE.ISEMenuItem. Todos os objetos de menu no menu Complementos são membros da classe Microsoft.PowerShell.Host.ISE.ISEMenuItem.
Propriedades
DisplayName
Propriedade somente leitura que obtém o nome do menu.
# Get the display name of the Add-ons menu item $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Clear() $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add("_Process",{get-process},"Alt+P") $psISE.CurrentPowerShellTab.AddOnsMenu.DisplayName
Action
Propriedade somente leitura que obtém o script (bloco) a ser invocado quando o item de menu recebe um clique.
# Get the action associated with the first submenu item. $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Clear() $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add("_Process",{get-process},"Alt+P") $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus[0].Action # Invoke the script associated with the first submenu item (Note the “.” At the beginning of the command). # Invoke the action $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus[0].Action.Invoke()
Shortcut
Propriedade somente leitura que obtém o gesto da chave de entrada do Windows para o item de menu.
# Get the shortcut for the first submenu item. $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Clear() $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add("_Process",{get-process},"Alt+P") $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus[0].Shortcut
Submenus
Propriedade somente leitura que obtém a lista de submenus do item de menu.
# List the submenus of the Add-ons menu $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Clear() $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add("_Process",{get-process},"Alt+P") $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus
Exemplo de script
Para entender melhor o uso do menu Complementos e de suas propriedades de script, leia o exemplo de script a seguir:
# This is a scripting example that shows the use of the Add-ons menu. # Clear the Add-ons menu if one exists $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Clear() # Add an Add-ons menu with an accessor. # Note the use of “_” as opposed to the “&” for mapping to the fast key letter for the menu item. $menuAdded = $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add("_Process",{get-process},"Alt+P") # Add a nested menu. $parentAdded = $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add("Parent",$null,$null) $parentAdded.SubMenus.Add("_Dir",{dir},"Ctrl+Shift+D")
See Also