此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* M1 \8 t) F: d. Y N T
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 f& }; p2 d2 }0 u7 i
方式一:
) s" o( L5 E/ Q/ }! v) t 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( n x" @' U- k1 V6 J
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
+ `( [% L$ Y! B& D) y HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。3 Z i$ |7 t5 C/ \" k4 R
方式二:: G9 j$ e# q0 F9 y9 M
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 K8 H( z4 ?( a j: y* v3 F* L8 w" S6 g
SetTitleMatchMode RegEx L5 T% k$ k8 [* _. F, v
return
$ U! b/ I$ B) x) O ; Stuff to do when Windows Explorer is open
( ?8 W5 a9 f) |/ V8 \/ d ;
, q0 S+ X! _+ O. a+ u+ Y( D #IfWinActive ahk_class ExploreWClass|CabinetWClass; r5 e: K3 h) w! D% k: w' r
; open ‘cmd’ in the current directory: }3 L7 o. R( v3 d
;
* _0 K$ n7 ]" W g Y2 T6 y #c::
0 X; s3 P6 ]: e! \0 e: } } OpenCmdInCurrent()& a( K1 g: @9 K j" F
return) {) y6 x6 e( @5 v* B
#IfWinActive
8 m9 P2 G5 D; B ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
8 n, `- d) |# C/ w+ u7 Z' _ ; Note: expecting to be run when the active window is Explorer.
9 y/ F w' }& {, L* q ;2 W( s- n1 r4 }* n7 j9 K" V
OpenCmdInCurrent()
7 E/ h1 Z0 z* G7 ^( Y& ~5 b {
# S& N6 B5 |! x* ^: M ; This is required to get the full path of the file from the address bar/ e# O+ O" _" d- |7 G9 O& Y1 R
WinGetText, full_path, A9 C' y; f) o8 ^/ t# Z3 f ~
; Split on newline (`n)
6 T0 e) d4 H; C. u! ` StringSplit, word_array, full_path, `n
; k5 w1 q# F9 a3 ]6 r8 X ; Take the first element from the array
9 Y& R1 F) d& W0 a$ |$ B9 U full_path = %word_array1%
" l& p9 e5 `. c) x8 M# Q0 [; u# u ; strip to bare address. l* t# ^5 I5 Q0 t$ [
full_path := RegExReplace(full_path, “地址: “, “”)# A9 Z; T2 M- Y, F+ ]4 u: s
; Just in case – remove all carriage returns (`r)- O1 g* I3 Q; o$ Y, Q; A
StringReplace, full_path, full_path, `r, , all
* U5 l, Q& \: Z+ u. M: Q/ q IfInString full_path, \3 a" l* u1 v; o8 G! p- w
{8 C1 ]- J& c. R, B9 Q8 [' u; o
Run, cmd /K cd /D “%full_path%”
% K$ p9 [* o2 [* ` }7 h# L' @4 }/ X, F$ M! `
else, y3 L. Q* ^ R$ d' W9 T- W
{# d" M8 b2 ~' I+ p+ r/ g, a. q
Run, cmd /K cd /D “C:\ ”2 V( q" ]9 ?# ]6 ^6 B
}
8 j+ Q/ V. _% S }
3 q- Y- D3 p, y3 s9 e/ B! q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% B9 _7 w( n& o" f" v! c
这段小代码肯能有两个你需要修改的地方
) E. r; }) ~, X) |* q- y 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键2 M8 y4 b' x" X. G o' z8 N
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
b0 N! { D' s7 l |