此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。2 B+ P: ]( k. Z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。0 A/ k: ?) c1 e G. ^8 l
方式一:
# [ s, H- X3 B5 z- E: O% O) ] 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
( x/ U4 `0 E% M+ e: C 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
$ i* R6 B, H: h$ H HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
7 y1 K0 _5 k% n% j! J6 L' w 方式二:/ U5 f C3 L5 E) R$ ?9 w& v/ H
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
, z2 Y3 K$ u8 o" h4 U* ~& e SetTitleMatchMode RegEx
: K1 X+ J& O4 ^( i: ] return' A4 o) t6 o$ X0 n7 {3 a' P
; Stuff to do when Windows Explorer is open
0 @1 q/ I( F( ~$ d+ K ;7 i* J8 L; J* g% b
#IfWinActive ahk_class ExploreWClass|CabinetWClass) p# a' [ @9 l- T& A# t5 O' g% F- `
; open ‘cmd’ in the current directory4 i4 R) M0 C* c* b4 d: u
;( O9 }( R) \; _* X. L z: V
#c::
# p* H/ Z$ U0 A- j7 e OpenCmdInCurrent()
# U# e+ H& m, x return
- U6 y g1 I, W$ y #IfWinActive# z: d' |( ] G. T1 a
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.4 {2 s2 Q. u+ n# N- t( b: ~
; Note: expecting to be run when the active window is Explorer.7 p$ a# [ ?$ {6 d
;
+ \. b" q% V' Z& ?+ z w% W$ j OpenCmdInCurrent()* T& h# g4 a; B, E% q
{
, y4 W; D6 X0 f* F% V ; This is required to get the full path of the file from the address bar2 c3 m* B' i+ J. R
WinGetText, full_path, A0 l% G0 T1 K1 X8 W
; Split on newline (`n)& w& n: J* [* F. Q, ^
StringSplit, word_array, full_path, `n
, b7 ~7 F" j* {7 e7 | ; Take the first element from the array
0 U, a) h' w4 r* G+ T full_path = %word_array1%8 r8 P+ h. o' Z# S
; strip to bare address
$ R1 Z; n+ i# `6 l. z+ \ full_path := RegExReplace(full_path, “地址: “, “”)% n- B! ]# g3 t* Z, N4 S( q6 Z
; Just in case – remove all carriage returns (`r)
7 [( T) C! b7 {; I8 T& K StringReplace, full_path, full_path, `r, , all) X, _, P) r/ W0 W8 I- c
IfInString full_path, \& P4 I( W7 x j
{+ R' |; \3 S' Q( |' _! b& L
Run, cmd /K cd /D “%full_path%”) J6 d9 v. ?7 x% ^
}
0 ?5 A& J. ~; E else+ ^2 S/ A( V' g! O; t2 A( J: l
{
`, a: j6 t& z6 k5 p! Y$ C" g( F Run, cmd /K cd /D “C:\ ”1 K! x% [+ {4 Q1 Q- W' C0 L
}
8 o5 ~! E7 D4 S) C: l }
) S% n5 _4 u r, _7 w. S+ \ Z 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。. D9 C: V8 U! k# E/ ^: c: _6 T
这段小代码肯能有两个你需要修改的地方
3 @) e: d" p u, G9 i4 Q% K% } 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
7 A2 G/ ]4 R2 a4 r: E 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
, \' H* y0 U9 G& a8 | I |