Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何分配Ctrl+;/作为Powershell中的关键手势_Powershell - Fatal编程技术网

如何分配Ctrl+;/作为Powershell中的关键手势

如何分配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.

我正在尝试使用这行代码指定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.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
    ,它可以同时使用
    /
    /
    键和数字键盘上的
    /