此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 [% D! S: e& b8 \ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. \2 A: }* H2 J2 N5 T
方式一:
, [6 b+ y4 I( l& z0 C 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% r4 Z9 A4 u6 S Z9 \ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 p$ D O8 C2 P) z
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! @; ]" \2 U% h: L* | 方式二:
( X" T- v0 |) A7 W8 D" ^& R 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( h# T( [: v1 P3 } SetTitleMatchMode RegEx) @- p* U. D4 P: p! G
return
; r7 C8 y! {, Q ; Stuff to do when Windows Explorer is open6 [9 T' R E7 ~5 g1 P9 m6 I
;/ O/ Y1 @& c2 V$ _5 F5 u
#IfWinActive ahk_class ExploreWClass|CabinetWClass- R5 f0 G/ I( W2 M! A: d
; open ‘cmd’ in the current directory
. {; ~, N6 V! ?1 b# Z ;
& d1 Q" \6 u# h7 a; s, J #c::
/ a1 k! v; _* r$ v6 b4 @. m" L OpenCmdInCurrent()2 t7 ? ~, t$ a. K9 V+ f
return) v( d$ E) U% v3 w; z2 ~
#IfWinActive
+ B h8 O+ ^2 J( @# X" g ; Opens the command shell ‘cmd’ in the directory browsed in Explorer., l8 L5 f8 Q: T5 n( X
; Note: expecting to be run when the active window is Explorer.
+ D! Y4 x3 b9 j4 f: I5 y x1 |9 Z ;
$ p5 p5 L2 C$ M: @ OpenCmdInCurrent()# U" b, `# I8 c
{: U; k4 a) ~1 K) z# d2 @2 |# B
; This is required to get the full path of the file from the address bar+ ]) e1 \ `* a2 ^4 y8 p
WinGetText, full_path, A+ q2 j4 q% {8 E- u+ Q7 U
; Split on newline (`n)
4 `8 r$ Z9 V8 I$ u$ g StringSplit, word_array, full_path, `n" U, d9 f1 a; s' J; b
; Take the first element from the array
& h5 b$ U- J. A5 z, n full_path = %word_array1%
* ?- B9 D4 ?8 V, ~0 ~8 R ; strip to bare address
% r+ j! a! a5 U4 H+ W$ m4 s2 q full_path := RegExReplace(full_path, “地址: “, “”)
0 R: J% ]2 A/ I! m ; Just in case – remove all carriage returns (`r)
o: i' b! q9 j StringReplace, full_path, full_path, `r, , all
. n/ a0 g3 \, S, A+ e* `( A% w IfInString full_path, \
0 {4 g3 a' W( w+ C$ h, }7 g {0 n* t- A4 g: o- M# Q& V
Run, cmd /K cd /D “%full_path%”+ ]) V: |# J5 q9 m$ ~; H' V5 e! z
}" F. B" f I: ^$ y
else
( B$ s$ M5 `' ?5 ?% S8 X {: j6 _* K( l3 n W. h6 B7 X8 {
Run, cmd /K cd /D “C:\ ”
5 t3 s* Z" J6 A! q" u8 B6 e8 H6 b }' L1 j" c9 [& P( W j
}4 Z! m& T$ [7 A" h3 s' K- w) F: F
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% q- z1 z' z/ l$ ?" f/ h
这段小代码肯能有两个你需要修改的地方- c& D( @! v: e: l9 b
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
2 s8 r' l3 ?9 M 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 J: q4 L8 Q3 `( [$ c9 Y. t |