此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
6 k" u0 y+ a( w5 S 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。; z r6 q4 f d8 w# t
方式一:! [7 q& Q, |- T8 }
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
+ a: i" P0 v) _1 Y3 T2 f8 c" o 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和, Y/ x) t# k# I' ], N6 ?
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
d' J, o5 y9 N7 v 方式二:
7 V! L6 R* H* ~; c( d4 k 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
9 x! H ]! j/ O9 F7 d' d" y3 ^8 K: Z) i3 ] SetTitleMatchMode RegEx5 B4 i4 }- W) K {5 x' A5 r7 @
return
% D n$ n) c9 `/ B) j) d ; Stuff to do when Windows Explorer is open. r' @# O9 c7 @9 B" a' o
;( h3 N: }4 q" L9 G. q' w
#IfWinActive ahk_class ExploreWClass|CabinetWClass
. F( o! W0 @6 S+ t4 h7 D ; open ‘cmd’ in the current directory
- G3 } q( R! H' f! ?. B ;" d$ J8 j* d3 L$ M: A% I
#c::
0 T6 D" r; _! `% Z OpenCmdInCurrent() j# X$ @3 r) N7 ^* ^, }$ t
return% f7 E# y: p, J3 a2 k
#IfWinActive6 c/ `! K( G$ k) _8 G: `
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
6 \" ]8 I$ _5 ]! Y4 _9 M/ e# k ; Note: expecting to be run when the active window is Explorer.5 `; v' Y$ v$ ~; C ], ^. L
;$ w9 i+ a, E, R6 s7 V9 I
OpenCmdInCurrent()( |4 ^! N# J0 H: l! N) j: v9 v
{! o! i" t, T: P+ ~/ f; w1 ?
; This is required to get the full path of the file from the address bar
2 e6 c# ]0 U; R" y9 q7 B WinGetText, full_path, A
+ J8 l- `9 r8 e# S+ u7 \/ l- S ; Split on newline (`n)3 U& w! p8 U/ |" \% ]
StringSplit, word_array, full_path, `n
* d- M) n/ b. l0 z& U" W. Y* U ; Take the first element from the array, V' s/ S) C( v+ L5 T
full_path = %word_array1%
\* r D2 R/ ~ ; strip to bare address
, L1 g Q3 N; _" D! b4 Y) l full_path := RegExReplace(full_path, “地址: “, “”)7 _: y' f( z0 \: j% z- U; W( @
; Just in case – remove all carriage returns (`r): Z$ M. k1 q/ X' q7 ?% X# q
StringReplace, full_path, full_path, `r, , all
5 f" S5 J, b# l! A1 ?" }: l IfInString full_path, \
% V3 W- t5 h7 F$ O {9 f8 P4 L$ W" l% o7 n4 b; o) D: Q
Run, cmd /K cd /D “%full_path%”
' n# H' C3 l" A9 X8 x }; c5 [& F- W5 m \7 x, O
else
T# B1 V* r- ]2 }" U* l {
' t. p8 `- T, ~" b! j Run, cmd /K cd /D “C:\ ”0 k& I2 n* b! z% Y5 x% k$ p
}
% g/ Q) S! B" ?& A }
# y1 H7 v ?2 h. h 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
' n; l0 E* D# ^$ [ m5 f4 U 这段小代码肯能有两个你需要修改的地方0 L* |2 [6 I) D% r
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 m+ a o$ O# B: C' T$ O; ?
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
( D# h$ y1 G0 E# E) @ |