此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 S" h. @% l' X4 h" z! S
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
% j, S) r/ j' ^8 f T 方式一:
" m* ]9 m+ S) K9 U; D 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
" {/ ~& N2 l+ }1 F6 x7 | 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和% |. u9 X' a$ B6 M$ f' Z: T/ ]6 i* s
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 `' C# B7 K. @# S" A
方式二:% P; L5 x0 a: w$ S/ \
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:# E( Z+ u2 j, k8 Y9 t9 \( @
SetTitleMatchMode RegEx
, X+ f3 Z4 K+ `4 E/ } x, ? return
. P; o- u; V( z ; Stuff to do when Windows Explorer is open+ ^: z e P, Y% Z8 w+ q3 j9 W
;8 ]4 g( _* p; Z$ V: N
#IfWinActive ahk_class ExploreWClass|CabinetWClass
8 A5 S( G+ O9 M) x {! O ; open ‘cmd’ in the current directory; U) x* x- p# l N; A% V7 {
;$ i) _6 B/ S) W7 p6 d9 N% Z3 M) ~
#c::
) T* h E& y& M+ ?$ B9 F OpenCmdInCurrent()
: c& H ]# ?" ^; w return; x; F# _! l) d) [) T
#IfWinActive; c4 @% W; E! \ A+ f% O
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.6 m* `% c) u5 F; p- d# N$ w
; Note: expecting to be run when the active window is Explorer.% `' z# L9 W+ ^# N
;, N# x0 N! v/ A6 O$ t& T4 E3 B: d
OpenCmdInCurrent()4 _6 M+ ^9 L+ x
{
/ j- Q" j4 M8 ]$ R& u2 q$ Y+ I) k ; This is required to get the full path of the file from the address bar7 u' q% I o/ y! f {4 i% q
WinGetText, full_path, A* b" b3 y5 q( U4 {7 {
; Split on newline (`n)
. K% f' c) @; j; Z t StringSplit, word_array, full_path, `n
1 g9 Y; @3 W" V7 N ; Take the first element from the array
7 J( Q, {( P8 q, l) I) N full_path = %word_array1%& l4 t& \: P! g$ }& g. g. o
; strip to bare address
" V( D0 K* i. r: A5 o7 O full_path := RegExReplace(full_path, “地址: “, “”)
% _, A6 q/ u: ?) f6 O* A ; Just in case – remove all carriage returns (`r)2 K$ W: Z9 U- a# t' z
StringReplace, full_path, full_path, `r, , all
* C( Y. Z' \. o7 a/ R IfInString full_path, \: _9 @% v4 c1 s* S3 k2 I
{. r8 H# T, @# v* n
Run, cmd /K cd /D “%full_path%”% u; `' {: g+ K# O
}" ~2 B/ h! e" r( A8 t' O0 ]
else- Q/ ?$ R; Y9 L2 B& S- A
{
2 M5 O s: ~& z. R) M2 ] Run, cmd /K cd /D “C:\ ”3 r4 M* R$ z; j4 A4 R
}! {6 K* h1 }- b: C5 ?# H5 T
}2 i% R9 }+ ^3 X1 ?
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- k* F, E# L" L, p) {! t" E
这段小代码肯能有两个你需要修改的地方5 V9 Y% h8 y0 w) s4 h
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键+ p1 j2 ]8 _6 f: E; V- u* ^1 @
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) a s X3 ] x2 ^% i2 N |