此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 z( G3 l9 G& Y( l$ K* m
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: ?8 D5 e. U0 \" c4 H! q# e" n0 w
方式一:6 D3 t1 n0 X. A& W: u" W" o
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ r C% b1 Y; n: t0 F3 _1 F
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和8 p+ M$ [! A# N/ `; g" ^ g
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" f/ w0 S9 i/ q+ N8 A: p1 K5 T 方式二:
* o8 |: F3 A( H! K9 N8 p K 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:+ F' s3 s# t9 i7 Y4 } m) A
SetTitleMatchMode RegEx8 `0 T1 U* m' ~. K, h! j
return
5 [ h W1 K' z+ w! V( j* C% L ; Stuff to do when Windows Explorer is open1 B2 I, Q+ p: J6 N& x4 P
;
. N: U6 I1 O2 q9 G) X0 X #IfWinActive ahk_class ExploreWClass|CabinetWClass
8 V& H6 a2 ^. s# X* R# r ; open ‘cmd’ in the current directory! r8 H( f% ^4 Y" p3 [2 q5 f1 t: N" J
;! [/ e, i2 f3 L0 v% p4 ^
#c::
# ?& `5 z1 {! }% j2 E* V4 [ OpenCmdInCurrent()# z, [' ]$ i4 @* P' V* K* K# O
return( X. ^2 w5 P8 F" t& p
#IfWinActive
7 z& C3 D+ k/ }1 Z% q3 i% F ; Opens the command shell ‘cmd’ in the directory browsed in Explorer., i8 d* n" Q, ` M
; Note: expecting to be run when the active window is Explorer.
. x. q3 S% z4 U ;- y8 B- J- s! E8 y" X/ [$ X1 k9 ?
OpenCmdInCurrent()2 O* j2 e* r& X+ D; J/ Z, Y
{# h" L$ {9 z7 j+ }* q ^: \
; This is required to get the full path of the file from the address bar$ P% G! ?" `3 u) l4 {! [
WinGetText, full_path, A* x% X0 I, j3 u/ G: E4 ~) S
; Split on newline (`n)6 s: e2 e2 ?9 H4 C; U
StringSplit, word_array, full_path, `n
- j6 `' G' P7 u0 p; H; l9 k ; Take the first element from the array z N [2 h% y1 B3 f. e, }, u
full_path = %word_array1%
1 W( _& M. r" `9 ] ; strip to bare address
5 n) t7 }) |; A full_path := RegExReplace(full_path, “地址: “, “”)5 Q' m o/ H, Y. Z" k& F& v
; Just in case – remove all carriage returns (`r)# J' ~5 U# z J! p! i
StringReplace, full_path, full_path, `r, , all
% r$ c+ J. N: v( g5 _+ l: o+ V IfInString full_path, \7 y) z' u: ~ a R) m: L
{
" Q, z/ o4 O Z Run, cmd /K cd /D “%full_path%”
7 F4 F+ V/ b8 f. n' M& z& Y }7 w- q2 U$ q8 n8 z
else9 h* b2 T% F3 F5 s6 U" c1 b6 T0 d
{
, B6 p# m5 q2 r! y Run, cmd /K cd /D “C:\ ”+ s; F$ u+ Q2 }) f; P
}( I9 Z8 \9 P: ~) J' ^- L
} R7 {3 U8 c$ S# h$ \+ m0 K* E
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" R4 a0 X7 z, Q! O! {
这段小代码肯能有两个你需要修改的地方& b. i1 R) B9 m* @3 E8 y1 I
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键+ A. v% Z2 o* V8 M4 w! l& x% ]$ R8 T9 D8 i
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, B/ f h( Z; H3 q0 T
|