|
1 |
| ---- |
2 |
| -ms.date: 2017-06-05 |
3 |
| -keywords: powershell,cmdlet |
4 |
| -title: The ISEMenuItem Object |
5 |
| -ms.assetid: a16660bd-0aee-46fd-ac17-3f022165d089 |
6 |
| ---- |
7 |
| - |
8 |
| -# The ISEMenuItem Object |
9 |
| - An **ISEMenuItem** object is an instance of the Microsoft.PowerShell.Host.ISE.ISEMenuItem class. All menu objects on the **Add-ons** menu are instances of the **Microsoft.PowerShell.Host.ISE.ISEMenuItem** class. |
10 |
| - |
11 |
| -## Properties |
12 |
| - |
13 |
| -### DisplayName |
14 |
| - Supported in Windows PowerShell ISE 2.0 and later. |
15 |
| - |
16 |
| - The read-only property that gets the display name of the menu item. |
17 |
| - |
18 |
| -``` |
19 |
| -# Get the display name of the Add-ons menu item |
20 |
| -$psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Clear() |
21 |
| -$psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add("_Process",{get-process},"Alt+P") |
22 |
| -$psISE.CurrentPowerShellTab.AddOnsMenu.DisplayName |
23 |
| -
|
24 |
| -``` |
25 |
| - |
26 |
| -### Action |
27 |
| - Supported in Windows PowerShell ISE 2.0 and later. |
28 |
| - |
29 |
| - The read-only property that gets the block of script. It invokes the action when you click the menu item. |
30 |
| - |
31 |
| -``` |
32 |
| -# Get the action associated with the first submenu item. |
33 |
| -$psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Clear() |
34 |
| -$psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add("_Process",{get-process},"Alt+P") |
35 |
| -$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus[0].Action |
36 |
| -
|
37 |
| -# Invoke the script associated with the first submenu item |
38 |
| -$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus[0].Action.Invoke() |
39 |
| -``` |
40 |
| - |
41 |
| -### Shortcut |
42 |
| - Supported in Windows PowerShell ISE 2.0 and later. |
43 |
| - |
44 |
| - The read-only property that gets the Windows input keyboard shortcut for the menu item. |
45 |
| - |
46 |
| -``` |
47 |
| -# Get the shortcut for the first submenu item. |
48 |
| -$psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Clear() |
49 |
| -$psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add("_Process",{get-process},"Alt+P") |
50 |
| -$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus[0].Shortcut |
51 |
| -``` |
52 |
| - |
53 |
| -### Submenus |
54 |
| - Supported in Windows PowerShell ISE 2.0 and later. |
55 |
| - |
56 |
| - The read-only property that gets the [list of submenus](The-ISEMenuItemCollection-Object.md) of the menu item. |
57 |
| - |
58 |
| -``` |
59 |
| -# List the submenus of the Add-ons menu |
60 |
| -$psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Clear() |
61 |
| -$psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add("_Process",{get-process},"Alt+P") |
62 |
| -$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus |
63 |
| -``` |
64 |
| - |
65 |
| -## Scripting example |
66 |
| - To better understand the use of the Add-ons menu and its scriptable properties, read through the following scripting example. |
67 |
| - |
68 |
| -``` |
69 |
| -
|
70 |
| -# This is a scripting example that shows the use of the Add-ons menu. |
71 |
| -# Clear the Add-ons menu if any entries currently exist |
72 |
| -$psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Clear() |
73 |
| -
|
74 |
| -# Add an Add-ons menu item with an shortcut and fast access key. |
75 |
| -# Note the use of “_” as opposed to the “&” for mapping to the fast access key letter for the menu item. |
76 |
| -$menuAdded = $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add("_Process",{get-process},"Alt+P") |
77 |
| -# Add a nested menu - a parent and a child submenu item. |
78 |
| -$parentAdded = $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add("Parent",$null,$null) |
79 |
| -$parentAdded.SubMenus.Add("_Dir",{dir},"Alt+D") |
80 |
| -
|
81 |
| -``` |
82 |
| - |
83 |
| -## See Also |
84 |
| -- [The ISEMenuItemCollection Object](The-ISEMenuItemCollection-Object.md) |
85 |
| -- [The Windows PowerShell ISE Scripting Object Model](The-Windows-PowerShell-ISE-Scripting-Object-Model.md) |
86 |
| -- [Windows PowerShell ISE Object Model Reference](Windows-PowerShell-ISE-Object-Model-Reference.md) |
87 |
| -- [The ISE Object Model Hierarchy](The-ISE-Object-Model-Hierarchy.md) |
| 1 | +--- ms.date: 2017-06-05 keywords: powershell,cmdlet title: The ISEMenuItem Object ms.assetid: a16660bd-0aee-46fd-ac17-3f022165d089 --- # The ISEMenuItem Object An **ISEMenuItem** object is an instance of the Microsoft.PowerShell.Host.ISE.ISEMenuItem class. All menu objects on the **Add-ons** menu are instances of the **Microsoft.PowerShell.Host.ISE.ISEMenuItem** class. ## Properties ### DisplayName Supported in Windows PowerShell ISE 2.0 and later. The read-only property that gets the display name of the menu item. ``` # 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 Supported in Windows PowerShell ISE 2.0 and later. The read-only property that gets the block of script. It invokes the action when you click the menu item. ``` # 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() ``` ### Shortcut Supported in Windows PowerShell ISE 2.0 and later. The read-only property that gets the Windows input keyboard shortcut for the menu item. ``` # 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 Supported in Windows PowerShell ISE 2.0 and later. The read-only property that gets the [list of submenus](The-ISEMenuItemCollection-Object.md) of the menu item. ``` # 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 ``` ## Scripting example To better understand the use of the Add-ons menu and its scriptable properties, read through the following scripting example. ``` # 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 an 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") ``` ## See Also - [The ISEMenuItemCollection Object](The-ISEMenuItemCollection-Object.md) - [The Windows PowerShell ISE Scripting Object Model](The-Windows-PowerShell-ISE-Scripting-Object-Model.md) - [Windows PowerShell ISE Object Model Reference](Windows-PowerShell-ISE-Object-Model-Reference.md) - [The ISE Object Model Hierarchy](The-ISE-Object-Model-Hierarchy.md) |
0 commit comments