此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* C( W4 f3 }% v
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
: r6 B* d( u" J' ]* ]1 w0 F, i 方式一:# C5 y; p$ r. n( M
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,7 z! l4 s* l1 Y' e$ I
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和 ]" x9 M& L. l
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" _0 W2 K+ }3 s: ~# C; B. B, A
方式二:, b" ^. C$ Z! M# q1 J2 z
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:$ a6 a; t; A6 @. E( ?9 Y' q
SetTitleMatchMode RegEx
& [3 ~- N- i' T# Z0 n return
7 D2 ~/ u% m- \( j& ?* v' s& l ; Stuff to do when Windows Explorer is open
$ ]$ k: I/ j+ `% V ;
8 X9 L" X, D$ E2 F' o/ ^, T #IfWinActive ahk_class ExploreWClass|CabinetWClass0 u, m; s/ F! J# ]5 Z
; open ‘cmd’ in the current directory
) i2 r7 o6 i& u: I" H ;' p5 q& Q, @4 r( K4 g- i c5 Q
#c::* s6 z) i( E: b8 C& y
OpenCmdInCurrent(); t8 Z! p S/ i2 b! y( y
return7 t! e' I) y, C% y+ h* P
#IfWinActive
! O9 i1 l f$ m0 x+ g ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.2 \$ a+ N: e0 Z1 r- [( B
; Note: expecting to be run when the active window is Explorer.+ ]2 V1 b9 W4 V& L! V/ g
;
% {+ Z+ n/ t7 T% h9 x OpenCmdInCurrent()2 a1 R8 l2 O% X
{& x- t, N/ X" U2 e! }. ^* `5 V# g
; This is required to get the full path of the file from the address bar) {" V- q$ I" U' E
WinGetText, full_path, A
% t& J% J, z" V+ o, v5 k ; Split on newline (`n); Z# d3 `# e0 Q: g: x& K
StringSplit, word_array, full_path, `n
, X6 t b4 |; o, I ; Take the first element from the array8 i/ N# k6 p+ J& u- ^$ o3 E( O
full_path = %word_array1%# S2 E, ^3 O3 `1 |1 n4 g. e
; strip to bare address
7 U5 e: A7 n4 c full_path := RegExReplace(full_path, “地址: “, “”)
- j1 E0 n1 J+ a) M6 n( e ; Just in case – remove all carriage returns (`r)
4 m8 x" b: G! b3 R StringReplace, full_path, full_path, `r, , all
9 l+ H) m1 ^% M% j% I IfInString full_path, \0 z# e8 H( G7 _ L( m5 A3 e
{
, e$ J- O' e) F- B2 v( r Run, cmd /K cd /D “%full_path%”4 B% U5 {0 ?2 J+ E- m& g
}
9 C7 u( m$ w' R3 b6 a else
9 l/ [0 [- z) y# @/ b {
4 T" A7 l' X0 G4 d Run, cmd /K cd /D “C:\ ”7 Q2 U% ~2 T1 Z( a
}! |. G/ H- `- Q2 r+ x+ D9 n2 t
}
8 n( O9 |: z/ {- K5 h. s A! [0 N 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。; v% c1 ^. L! i+ k, i( `
这段小代码肯能有两个你需要修改的地方. T4 k9 f( u& H2 r0 O( E4 I$ Z
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键 y$ d' ` f* f+ B8 a' F9 X
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
# z) ~! a2 ^( K6 w$ X* o( B; D |