在Windows XP上,是否有快捷键可以将剪贴板的内容粘贴到命令提示符窗口中(而不是使用鼠标右键)?

典型的Shift+Insert在这里似乎不起作用。


当前回答

我个人使用一个小的AutoHotkey脚本来重新映射某些键盘功能,对于我使用的控制台窗口(CMD):

; Redefine only when the active window is a console window 
#IfWinActive ahk_class ConsoleWindowClass

; Close Command Window with Ctrl+w
$^w::
WinGetTitle sTitle
If (InStr(sTitle, "-")=0) { 
    Send EXIT{Enter}
} else {
    Send ^w
}

return 


; Ctrl+up / Down to scroll command window back and forward
^Up::
Send {WheelUp}
return

^Down::
Send {WheelDown}
return


; Paste in command window
^V::
; Spanish menu (Editar->Pegar, I suppose English version is the same, Edit->Paste)
Send !{Space}ep
return

#IfWinActive 

其他回答

谢谢,巴勃罗,这正是我要找的!但是,如果我可以冒昧地稍微改进您的脚本,我建议用以下代码替换您的^V宏:

; Use backslash instead of backtick (yes, I am a C++ programmer).
#EscapeChar \

; Paste in command window.
^V::
StringReplace clipboard2, clipboard, \r\n, \n, All
SendInput {Raw}%clipboard2%
return

使用SendInput的优点是

它不依赖于命令提示系统菜单中有“Alt+Space E P”菜单项来进行粘贴(适用于英语和西班牙语,但不适用于所有语言)。 它避免了你在创建和销毁菜单时看到的讨厌的闪烁。

注意,在SendInput命令中包含“{Raw}”是很重要的,以防剪贴板碰巧包含“!”,“+”,“^”或“#”。

注意,它使用StringReplace删除多余的Windows回车字符。谢谢hugov的建议!

你可以尝试使用Texter并创建一些不太可能的东西,如:

./p,由空格触发并将文本替换为%c

我刚刚测试了一下,它工作得很好。唯一的问题是使用一个罕见的序列,因为Texter不能限制这只是cmd。

可能还有其他类似的工具可以工作,甚至AutoHotKey,在此基础上构建的Texter可以做得更好,但Texter很容易:-)

一个更简单的方法是使用windows powershell而不是cmd。它的工作很好与文本。

不是真的编程相关,但我在谷歌上找到了这个,没有直接的键盘快捷键,但使它更快一点。

启用/关闭快速kedit模式。

Open the MS-DOS program, or the command prompt. Right-click the title bar and press Properties. Select the Options tab. Check or un-check the QuickEdit Mode box. Press OK. In the Apply Properties To Shortcut dialog, select the Apply properties to current window only if you wish to change the QuickEdit setting for this session of this window only, or select Modify shortcut that started this window to change the QuickEdit setting for all future invocations of the command prompt, or MS-DOS program.

当quickkedit启用时,复制文本:

单击并将鼠标指针拖动到所需文本上。 按Enter(或右键单击窗口中的任何位置)将文本复制到剪贴板。

在启用quickkedit时粘贴文本:

右键单击窗口中的任意位置。

当quickkedit被禁用时复制文本:

右键单击标题栏,按菜单上的“编辑”,然后按“标记”。 将鼠标拖到要复制的文本上。 按Enter(或右键单击窗口中的任何位置)将文本复制到剪贴板。

在禁用quickkedit时粘贴文本:

右键单击标题栏,按菜单上的编辑,然后按粘贴。

这不是一个真正的快捷方式,但只是一个快速访问控制菜单:Alt-space E P

如果你可以使用你的鼠标,右键单击cmd窗口作为粘贴时,我尝试了它。