此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 ~! G7 e! {7 |# P- B# Z 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 \ Q+ L; G2 N' a6 T2 g 方式一:
9 }5 r& }; A H4 d) B N 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
+ L" }) x4 o# a- x. X {3 c* q 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
- b) _' m: f `0 [8 b HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
. ?# d& M8 m" p) _- O 方式二:
3 C7 N9 J6 k2 i; E \6 w9 R 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:2 i: ]0 W3 w) d6 Q4 k5 Z) {
SetTitleMatchMode RegEx! f, _4 r D1 ]+ V
return
- @ o! M) I/ k0 Z/ Z' j: k' I9 T ; Stuff to do when Windows Explorer is open
5 g5 {+ C) m! F/ B! Z/ i ;. i' |3 N4 p2 J; l4 \5 D
#IfWinActive ahk_class ExploreWClass|CabinetWClass% z+ c" T4 q6 P& I+ r' E4 D
; open ‘cmd’ in the current directory( [. c: m; u5 B7 i# P5 v2 Y
;( Z7 T) o- w7 | ~
#c::
/ T* K6 E; d# [$ D% | OpenCmdInCurrent()7 \2 _$ l! v1 `' ]# k0 O/ m
return
7 N6 P+ q* M( M( D7 D #IfWinActive
! x D" T; \4 e3 D# y ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
" d2 i# u: x& e. f7 q ; Note: expecting to be run when the active window is Explorer.3 r) z8 Q: H( U( Q7 e& Q; Q
;
- V9 \" f# y; O& [) z OpenCmdInCurrent()
" _- [( B: u A3 x, f" d6 | {
3 @$ B" y( Y* F% ` T' b# u5 e ; This is required to get the full path of the file from the address bar
# c; L( _/ F2 _1 Q# M WinGetText, full_path, A
# P) P) |4 a, j+ b% T* L ; Split on newline (`n)
7 {! b) b5 F% i8 I2 t4 R- W StringSplit, word_array, full_path, `n3 b- h. Y Q- O3 D
; Take the first element from the array
& _% m4 B( H5 D2 g. P full_path = %word_array1%; a7 r2 \( I. m) K4 a0 B' Z% a
; strip to bare address$ p9 p L' Z! U7 @! a0 |% H
full_path := RegExReplace(full_path, “地址: “, “”)
3 J, M/ t% {0 ~/ u; y. I ; Just in case – remove all carriage returns (`r)
- F2 U* y; }& ?! a% Y StringReplace, full_path, full_path, `r, , all0 |6 p/ h8 x) O, f
IfInString full_path, \
M2 j/ J0 ]! [. d: E7 ?+ u1 R3 J {! o' s0 o% B" g, N
Run, cmd /K cd /D “%full_path%”5 v! w$ p9 v+ M: ^% \- u
}8 S6 H# m+ c/ t8 [, _' u
else* p7 B% M0 P. [( K) t8 ?
{+ x* b. ^% J5 A( b+ E9 e" T) V
Run, cmd /K cd /D “C:\ ”
; b/ t1 {/ S- R4 H8 y( y* X }8 U) @4 F, C7 ?. c% N9 U
}
. j( q5 w& D3 ] 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- E6 o; O3 z# M. y+ ?6 ~* d% E 这段小代码肯能有两个你需要修改的地方
/ E9 n/ |) p( j2 f7 K* k 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) T5 s" z# U8 h4 G9 w- F3 X
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: a) g$ K. x3 d F
|