`

扩展Windows命令行窗口(cmd),支持复制粘贴等操作

阅读更多

扩展的方法是使用AutoHotKey。

 

最早看到这一主题,是在下面这篇blog

通过AutoHotKey让命令行窗口cmd.exe支持 CTRL-C CTRL-V

 

但是正如上面那篇blog的作者slimzhao 中讨论的那样,使用其中记载的方法时,会有一些小困扰(主要问题是依赖于鼠标位置)。于是我顺着这一问题继续狗,终于找到了这个帖子。透过键盘,问题算是得到了完美的解决,然而美中不足的是:他需要依赖Windows的快捷键Alt+Space,而这一快捷键已经被我分配给了Launchy。

Keyboard shortcut to paste clipboard content into command prompt window (Win XP)

 

这一问题让我十分纠葛,经过我个人的反复试用,我决定依旧将Alt+Space分配给Launchy,而忍受使用鼠标来扩展windows命令行窗口。话不多说,直接山两种方式的AutoHotKey脚本:

他们会扩展windows的cmd窗口,使其支持如下快捷键:

写道
粘贴:Ctrl+V
关闭:Ctrl+W
查找:Ctrl+F
向上滚屏:Ctrl+Up
向下滚屏:Ctrl+Down

另:保留Ctrl+C为结束命令用。

 

第一种扩展方式(使用键盘模拟, Alt+Space)的AutoHotKey脚本

; 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


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


#IfWinActive

     

 

第二种扩展方式(使用鼠标模拟, 保留Alt+Space)的AutoHotKey脚本

; 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)
; paste method use alt+space
;Send !{Space}ep
; paste method not use alt+space
MouseClick, Right
send,  p
return

; find in command window
^F::
; find method use alt+space
;Send !{Space}ef
; find method not use alt+space
MouseClick, Right
send,  f
return

#IfWinActive

 

 

 

附注,我的另外两篇关于命令行窗口的blog:

Windows命令行窗口中的快捷键
Windows: 也谈“触手可及的命令提示符”

 

 

 

 

 

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics