此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* y* ~4 B3 s+ w) @
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 v9 J; C& X, u. h) D2 C
方式一:; [' d& h4 K1 |- P& Y
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
5 z3 K( N3 d" V( V0 I 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' H3 |; j" P2 l, r6 g) I% P
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ y# e8 Z& {5 S6 H; m* x
方式二:
, |1 A/ M7 j* ?( Q, x* C 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
0 @* h9 }) q5 j' R/ r6 N SetTitleMatchMode RegEx
2 y: t( e1 v0 V2 q! @. Q return2 {7 H4 J7 c2 \& j: q5 `
; Stuff to do when Windows Explorer is open* {: o$ \4 o2 I. }
;) `2 Q5 X& y5 n$ Z$ H+ [
#IfWinActive ahk_class ExploreWClass|CabinetWClass. w8 [+ m5 A" A9 ^( X ^; d
; open ‘cmd’ in the current directory1 Z! L" ]# \1 q7 e: A
;
+ x6 c: r7 D. p #c::
?% s* Z* F* v [4 C3 i8 a: R3 i$ ^ OpenCmdInCurrent()& y( b8 J0 W7 p
return
, W' G5 ]# R. R1 ~! ~& A7 y #IfWinActive
. p% B$ ?( d+ v+ | ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ m: q& O1 Y7 K2 N' w7 l4 H ; Note: expecting to be run when the active window is Explorer.* b' ?, n# g2 W* K
;& H; i o( k3 I
OpenCmdInCurrent()
7 m2 _+ _: z- U V9 K {" ^& Q8 M9 a, k8 A1 p! n3 S3 w
; This is required to get the full path of the file from the address bar
. ?; s% }3 ^' Y# F( G. I3 v WinGetText, full_path, A
2 r& Z, S m$ a( m' _7 z ; Split on newline (`n)
8 F+ b3 P5 J/ Q n( s8 J StringSplit, word_array, full_path, `n' l, m" A3 ~; \3 Q" k
; Take the first element from the array* |* N {+ v8 V) i/ Z( ~
full_path = %word_array1%
8 U! |# _" L8 [( K% _ ; strip to bare address1 b7 h' O% e _: z
full_path := RegExReplace(full_path, “地址: “, “”)
5 M/ O, n2 j. H$ t ; Just in case – remove all carriage returns (`r)
: S2 ?. j/ g9 ]4 r7 u0 t) L StringReplace, full_path, full_path, `r, , all( J, q7 T9 z, w+ ^, }
IfInString full_path, \5 a" b& O! @; {2 A' B. k0 |) c
{
& j2 ~4 D, O) R' \& y/ K, s Run, cmd /K cd /D “%full_path%”& |0 a& c$ s# {7 b1 |
}
E# j. X8 d% d, x* q0 o else
2 N" D, U! X* K; `* e) N" ` {
. Y& |, s+ X& t+ L; B4 ~ Run, cmd /K cd /D “C:\ ”$ g3 ^& P$ x5 h, p
}7 A) H: @! l) u$ w# Z3 `
}
j7 Y9 J$ Q% ^& F. O9 E, W 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
) O# ?) U9 T6 X6 _/ b 这段小代码肯能有两个你需要修改的地方
1 D; p T. x' T4 N7 G" d 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. Y+ b4 ]# \" Q% e) R2 w& c( t 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
, @+ c3 O" }, ^& K( s' O |