如何分配Ctrl+;/作为Powershell中的关键手势
我正在尝试使用这行代码指定powershell ISE的快捷方式如何分配Ctrl+;/作为Powershell中的关键手势,powershell,Powershell,我正在尝试使用这行代码指定powershell ISE的快捷方式 $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Comment Selected Lines",{Comment-IseSelectedLines},"Ctrl+/") 但我犯了这个错误 Cannot convert argument "shortcut", with value: "Ctrl+/", for "Add" to type "System.Windows.
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Comment Selected Lines",{Comment-IseSelectedLines},"Ctrl+/")
但我犯了这个错误
Cannot convert argument "shortcut", with value: "Ctrl+/", for "Add" to type
"System.Windows.Input.KeyGesture": "Cannot convert value "Ctrl+/" to type
"System.Windows.Input.KeyGesture". Error: "Requested value '/' was not found.""
如果我换成另一个字母,比如说O,错误就会消失。 那么,我还有什么可以用的吗
这就是我最终使用的代码
#Ctrl + /
$KeyGesture = New-Object -TypeName System.Windows.Input.KeyGesture -ArgumentList ([System.Windows.Input.Key]::OemQuestion, [System.Windows.Input.ModifierKeys]::Control);
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Comment Selected Lines",{Comment-IseSelectedLines},$KeyGesture)
#ctrl + Shift + /
$KeyGesture = New-Object -TypeName System.Windows.Input.KeyGesture -ArgumentList ([System.Windows.Input.Key]::OemQuestion, 6)
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Uncomment Selected Lines",{Uncomment-IseSelectedLines},$KeyGesture)
以下是如何对其进行研究:
System.Windows.Input.keypostate
类;e、 g:keyperstation
类有一个名为Key
的成员,它是一个枚举,是可用键的列表:/
键。它不在那里,但是有一个除法和一个OemQuestion
Ctrl+OemQuestion
,它可以同时使用/
/?
键和数字键盘上的/
键