HI 大家下午好,之前一段时间部署实施上线lync企业语音,导致暂停更新powershell系列博文,目前开始逐步恢复。
在今后我会详细讲解一下关于windows server 2012 R2 中关于poweshell 带给我们的惊喜。
好了直奔主题,今天我们来说说如何在ISE 3.0展示键盘快捷键的完整列表
其实所有快捷键都包含在的ISE Microsoft.PowerShell.GPowerShell 组件(DLL)

首先,我们需要得到一个参考该DLL。

PS> $gps = $psISE.GetType().Assembly
PS> $gps
                                                                                                                                                                                                             
GAC    Version        Location
---    -------        --------
True   v4.0.30319     C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.GPowerShell\...
 


然后我们执行GetManifestResourceNames 来得到这个组件的所有资源列表

PS> $gps.GetManifestResourceNames()
                                                                                                                                                       
Microsoft.PowerShell.GPowerShell.g.resources
GuiStrings.resources


接下来我们创建一个ResourceManager对象的资源提供访问。名称来显示它的资源,我们要访问没有资源扩展的该资源的组件。
$rm = New-Object System.Resources.ResourceManager GuiStrings,$gps


所有剩下的就是调用GetResourceSet()方法来检索设置为一个特定的项目详细

$rs = $rm.GetResourceSet((Get-Culture),$true,$true)
$rs
                                                                                                           
Name                           Value
----                           -----
SnippetToolTipPath             Path: {0}
MediumSlateBlueColorName       Medium Slate Blue
EditorBoxSelectLineDownShor... Alt+Shift+Down (★)
NewRunspace                    N_ew PowerShell Tab
EditorSelectToPreviousChara... Shift+Left(★)
RemoveAllBreakpointsShortcut   Ctrl+Shift+F9(★)
SaveScriptQuestion             Save {0}?
(...)


我们看上面输出的结果,我可以看到我标注的(★)突出显示的项目值,类似的组合键。
如果看看我的输出,你会发现项目的名称结尾的“快捷方式” (带或不带结尾的数字),涉及到的功能键。

它们开始,后边会跟一个数字或两个“键盘”字,然后我们执行下面的一行代码,我们可以过滤所有的键盘相关物项和整理出来。


$rs | where Name -match 'Shortcut\d?$|^F\d+Keyboard' | Sort-Object Value


下面是完整的代码片段和完整的结果
$gps = $psISE.GetType().Assembly
$rm = New-Object System.Resources.ResourceManager GuiStrings,$gps
$rs = $rm.GetResourceSet((Get-Culture),$true,$true)
$rs | where Name -match 'Shortcut\d?$|^F\d+Keyboard' | Sort-Object Value | Format-Table -AutoSize
                                                    
Name                                            Value
----                                            -----
EditorUndoShortcut2                             Alt+Backspace
EditorSelectNextSiblingShortcut                 Alt+Down
ExitShortcut                                    Alt+F4
EditorSelectEnclosingShortcut                   Alt+Left
EditorSelectFirstChildShortcut                  Alt+Right
EditorRedoShortcut2                             Alt+Shift+Backspace
EditorBoxSelectLineDownShortcut                 Alt+Shift+Down
ToggleHorizontalAddOnPaneShortcut               Alt+Shift+H
EditorBoxSelectToPreviousCharacterShortcut      Alt+Shift+Left
EditorBoxSelectToNextCharacterShortcut          Alt+Shift+Right
EditorTransposeLineShortcut                     Alt+Shift+T
EditorBoxSelectLineUpShortcut                   Alt+Shift+Up
ToggleVerticalAddOnPaneShortcut                 Alt+Shift+V
EditorSelectPreviousSiblingShortcut             Alt+Up
ShowScriptPaneTopShortcut                       Ctrl+1
ShowScriptPaneRightShortcut                     Ctrl+2
ShowScriptPaneMaximizedShortcut                 Ctrl+3
EditorSelectAllShortcut                         Ctrl+A
ZoomIn1Shortcut                                 Ctrl+Add
EditorMoveCurrentLineToBottomShortcut           Ctrl+Alt+End
EditorMoveCurrentLineToTopShortcut              Ctrl+Alt+Home
EditorDeleteWordToLeftShortcut                  Ctrl+Backspace
StopExecutionShortcut                           Ctrl+Break
StopAndCopyShortcut                             Ctrl+C
GoToConsoleShortcut                             Ctrl+D
EditorDeleteWordToRightShortcut                 Ctrl+Del
EditorScrollDownAndMoveCaretIfNecessaryShortcut Ctrl+Down
EditorMoveToEndOfDocumentShortcut               Ctrl+End
FindShortcut                                    Ctrl+F
ShowCommandShortcut                             Ctrl+F1
CloseScriptShortcut                             Ctrl+F4
GoToLineShortcut                                Ctrl+G
ReplaceShortcut                                 Ctrl+H
EditorMoveToStartOfDocumentShortcut             Ctrl+Home
GoToEditorShortcut                              Ctrl+I
Copy2Shortcut                                   Ctrl+Ins
ShowSnippetShortcut                             Ctrl+J
EditorMoveToPreviousWordShortcut                Ctrl+Left
ToggleOutliningExpansionShortcut                Ctrl+M
ZoomOut3Shortcut                                Ctrl+Minus
NewScriptShortcut                               Ctrl+N
OpenScriptShortcut                              Ctrl+O
GoToMatchShortcut                               Ctrl+Oem6
ZoomIn3Shortcut                                 Ctrl+Plus
ToggleScriptPaneShortcut                        Ctrl+R
EditorMoveToNextWordShortcut                    Ctrl+Right
SaveScriptShortcut                              Ctrl+S
ZoomIn2Shortcut                                 Ctrl+Shift+Add
GetCallStackShortcut                            Ctrl+Shift+D
EditorSelectToEndOfDocumentShortcut             Ctrl+Shift+End
RemoveAllBreakpointsShortcut                    Ctrl+Shift+F9
HideHorizontalAddOnToolShortcut                 Ctrl+Shift+H
EditorSelectToStartOfDocumentShortcut           Ctrl+Shift+Home
ListBreakpointsShortcut                         Ctrl+Shift+L
EditorSelectToPreviousWordShortcut              Ctrl+Shift+Left
ZoomOut4Shortcut                                Ctrl+Shift+Minus
StartPowerShellShortcut                         Ctrl+Shift+P
ZoomIn4Shortcut                                 Ctrl+Shift+Plus
NewRemotePowerShellTabShortcut                  Ctrl+Shift+R
EditorSelectToNextWordShortcut                  Ctrl+Shift+Right
ZoomOut2Shortcut                                Ctrl+Shift+Subtract
EditorMakeUppercaseShortcut                     Ctrl+Shift+U
HideVerticalAddOnToolShortcut                   Ctrl+Shift+V
IntellisenseShortcut                            Ctrl+Space
ZoomOut1Shortcut                                Ctrl+Subtract
NewRunspaceShortcut                             Ctrl+T
EditorMakeLowercaseShortcut                     Ctrl+U
EditorScrollUpAndMoveCaretIfNecessaryShortcut   Ctrl+Up
Paste1Shortcut                                  Ctrl+V
CloseRunspaceShortcut                           Ctrl+W
Cut1Shortcut                                    Ctrl+X
EditorRedoShortcut1                             Ctrl+Y
EditorUndoShortcut1                             Ctrl+Z
F1KeyboardDisplayName                           F1
HelpShortcut                                    F1
StepOverShortcut                                F10
F10KeyboardDisplayName                          F10
StepIntoShortcut                                F11
F11KeyboardDisplayName                          F11
F12KeyboardDisplayName                          F12
F2KeyboardDisplayName                           F2
FindNextShortcut                                F3
F3KeyboardDisplayName                           F3
F4KeyboardDisplayName                           F4
RunScriptShortcut                               F5
F5KeyboardDisplayName                           F5
F6KeyboardDisplayName                           F6
F7KeyboardDisplayName                           F7
RunSelectionShortcut                            F8
F8KeyboardDisplayName                           F8
F9KeyboardDisplayName                           F9
ToggleBreakpointShortcut                        F9
EditorDeleteCharacterToLeftShortcut             Shift+Backspace
Cut2Shortcut                                    Shift+Del
EditorSelectLineDownShortcut                    Shift+Down
EditorSelectToEndOfLineShortcut                 Shift+End
EditorInsertNewLineShortcut                     Shift+Enter
StepOutShortcut                                 Shift+F11
FindPreviousShortcut                            Shift+F3
StopDebuggerShortcut                            Shift+F5
EditorSelectToStartOfLineShortcut               Shift+Home
Paste2Shortcut                                  Shift+Ins
EditorSelectToPreviousCharacterShortcut         Shift+Left
EditorSelectPageDownShortcut                    Shift+PgDn
EditorSelectPageUpShortcut                      Shift+PgUp
EditorSelectToNextCharacterShortcut             Shift+Right
EditorSelectLineUpShortcut                      Shift+Up


看起来很多,其实只需要记住几个常用的即可。