Un oggetto ISEMenuItem è un'istanza della classe Microsoft.PowerShell.Host.ISE.ISEMenuItem. Tutti gli oggetti del menu Componenti aggiuntivi sono membri della classe Microsoft.PowerShell.Host.ISE.ISEMenuItem.

Proprietà

DisplayName

Proprietà di sola lettura che ottiene il nome del 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

Azione

Proprietà di sola lettura che ottiene lo script (blocco) da richiamare quando si fa clic sulla voce di menu.

# 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

Proprietà di sola lettura che ottiene il movimento della chiave di input di Windows per la voce di 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

Proprietà di sola lettura che ottiene l'elenco di sottomenu della voce di 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

Esempio di scripting

Per comprendere meglio l'utilizzo del menu Componenti aggiuntivi e delle relative proprietà di script, consultare l'esempio di scripting seguente:

# 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")

Vedere anche




Argomenti della Guida