Obiekt ISEMenuItem

Obiekt ISEMenuItem jest wystąpieniem klasy Microsoft.PowerShell.Host.ISE.ISEMenuItem . Wszystkie obiekty menu w menu Dodatki są wystąpieniami klasy Microsoft.PowerShell.Host.ISE.ISEMenuItem .

Właściwości

DisplayName

Obsługiwane w programie Windows PowerShell ISE 2.0 lub nowszym.

Właściwość tylko do odczytu, która pobiera nazwę wyświetlaną elementu 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

Akcja

Obsługiwane w programie Windows PowerShell ISE 2.0 lub nowszym.

Właściwość tylko do odczytu, która pobiera blok skryptu. Wywołuje akcję po kliknięciu elementu 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
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus[0].Action.Invoke()

Skrót

Obsługiwane w programie Windows PowerShell ISE 2.0 lub nowszym.

Właściwość tylko do odczytu, która pobiera skrót klawiaturowy systemu Windows dla elementu 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

Obsługiwane w programie Windows PowerShell ISE 2.0 lub nowszym.

Właściwość tylko do odczytu, która pobiera listę podmenu elementu 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

Przykład tworzenia skryptów

Aby lepiej zrozumieć użycie menu Dodatków i jego właściwości skryptowych, zapoznaj się z poniższym przykładem skryptu.

# This is a scripting example that shows the use of the Add-ons menu.
# Clear the Add-ons menu if any entries currently exist
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Clear()

# Add an Add-ons menu item with a shortcut and fast access key.
# 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')
# Add a nested menu - a parent and a child submenu item.
$parentAdded = $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add('Parent', $null, $null)
$parentAdded.SubMenus.Add('_Dir', {dir}, 'Alt+D')

Zobacz też