Objek ISEMenuItem

Objek ISEMenuItem adalah instans kelas Microsoft.PowerShell.Host.ISE.ISEMenuItem . Semua objek menu pada menu Add-on adalah instanskelas Microsoft.PowerShell.Host.ISE.ISEMenuItem .

Properti

DisplayName

Didukung di Windows PowerShell ISE 2.0 dan yang lebih baru.

Properti baca-saja yang mendapatkan nama tampilan item 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

Perbuatan

Didukung di Windows PowerShell ISE 2.0 dan yang lebih baru.

Properti baca-saja yang mendapatkan blok skrip. Ini memanggil tindakan saat Anda mengklik item 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()

Pintasan

Didukung di Windows PowerShell ISE 2.0 dan yang lebih baru.

Properti baca-saja yang mendapatkan pintasan keyboard input Windows untuk item 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

Didukung di Windows PowerShell ISE 2.0 dan yang lebih baru.

Properti baca-saja yang mendapatkan daftar submenu item 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

Contoh pembuatan skrip

Untuk lebih memahami penggunaan menu Add-on dan properti yang dapat ditulis, baca contoh pembuatan skrip berikut.

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

Lihat Juga