此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, y$ A8 {* X" p z8 y' Z2 ]
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。3 L/ o, i* L0 y- W6 q
方式一:0 L \/ a9 _ h1 e
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- y9 y# C* x7 G2 G2 x
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
+ k% J6 Z( F* o, y1 Y" @3 N HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 @9 f |: R# @- Q 方式二:
, \+ `3 X! f: j9 m# P6 {1 M* E. o& M/ S 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
3 S0 r, D* [+ S# X SetTitleMatchMode RegEx
- P; x4 t4 J5 m$ n return. y0 n# ^% F! [# j* g
; Stuff to do when Windows Explorer is open+ R; s7 L8 m3 k. }7 R$ w
;
6 x, K+ h& @' T #IfWinActive ahk_class ExploreWClass|CabinetWClass/ T ]- ?; D& E
; open ‘cmd’ in the current directory
- K1 c" p5 x# F ;
+ C7 B! x7 w/ p4 A: b# j #c::7 R6 u& Z% S0 u( z$ X7 ]( m
OpenCmdInCurrent()( h2 l- \7 t6 \$ h& {6 R9 ] f7 Y4 v
return1 N* u3 P3 V: h2 O. G5 }; @
#IfWinActive
4 J7 O& {- I' O/ p* w: \! B; I( e ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
" m! V9 F/ D! E/ O; U/ ]1 O ; Note: expecting to be run when the active window is Explorer.; L( }5 Y0 s+ ?) z1 Q0 X, F
;4 W1 [0 m2 L* c. L8 t
OpenCmdInCurrent()
6 `$ h1 Y7 b# `: a {
8 n+ ^( }& C" j. c9 `. C ; This is required to get the full path of the file from the address bar! ~5 F5 m, }) v# y
WinGetText, full_path, A6 a& ]* k3 m2 Y4 Z+ _
; Split on newline (`n)
h. c H( I* z; N$ k/ @ StringSplit, word_array, full_path, `n- b8 m8 v) Y9 a- j c* P2 J
; Take the first element from the array
0 c- _4 e- c+ Z! Y+ i full_path = %word_array1%
$ ], ^. @; L4 R1 O9 f2 M' I8 [ ; strip to bare address
; U" f4 z8 |, b9 U full_path := RegExReplace(full_path, “地址: “, “”)
' g% l. d8 P/ y j1 p ; Just in case – remove all carriage returns (`r)6 p5 V$ d# r, S& Z
StringReplace, full_path, full_path, `r, , all
8 P$ i" E& Y) U; d: q: g IfInString full_path, \
0 q- V. W" `" l( f& n! x5 m& O {
' ~7 g9 ?7 k& f4 a: v& \ Run, cmd /K cd /D “%full_path%”
5 Q1 h6 ]2 R. g9 A }
: ` ~- W+ T1 ^; X" _9 w) | else* e6 b' x1 p) n' d6 Q0 y
{& i& x6 M! a: r
Run, cmd /K cd /D “C:\ ”
/ B9 O2 j" u7 j0 u6 k; K/ t }0 S& F2 u8 W7 x! _' a
}
5 J) P# k& ? a4 p$ p5 }" v! z 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
' b8 u! O, x5 t& e+ q6 P2 \* z 这段小代码肯能有两个你需要修改的地方
% ]. q- Z5 ^* X' s% z$ @ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
5 P4 @# N4 ^% }' d 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “7 {9 ?2 [5 J, S( j- W0 v8 L
|