此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' Q* ]2 h5 {' ] T( M. M; A
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
' J1 ?* g2 E8 w- \# ^' h+ L 方式一:
4 M* f3 a- ^, O9 _+ U7 |2 [ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
, J0 X& e+ y: e& g* p+ v: R 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和( j' g2 C7 n7 `2 ^( u
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ w2 Y) i* x9 H* Y/ p
方式二:- M& g! k4 C, C7 d$ ~) w- ~
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- {" C% C% S. Z/ i) I* b' Z( e y4 k% b) m SetTitleMatchMode RegEx
3 t' x: l8 Y! i' c3 v! x return
9 A, T- [ Q) f/ y5 M. T5 I ; Stuff to do when Windows Explorer is open q2 y: s. K4 o. W+ E0 }
;4 E( f0 F. d3 O! Y7 H0 s
#IfWinActive ahk_class ExploreWClass|CabinetWClass+ P9 a i/ Q/ ^
; open ‘cmd’ in the current directory, k* }. k. @8 U# d7 Y. x7 F
;' L! Q$ f( s! w+ }& X# h( V+ k
#c::
p4 K8 D( x+ s3 d; y: ] OpenCmdInCurrent()
& V6 Q V) A7 V0 U: W: O8 N return
" K7 F2 a- F& f1 l* w #IfWinActive
9 g; B, @+ [5 R- x, m; @3 I ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 Q/ C3 ?( F9 T( n ; Note: expecting to be run when the active window is Explorer.
: T; a/ N7 b1 Y) \& H ;
. T, D+ Q# i* x$ {9 `1 O; q% _& l OpenCmdInCurrent()
' w) y4 ?' d; F4 x3 j {- |3 D. x: V2 L0 ]5 z
; This is required to get the full path of the file from the address bar
" T& |6 t& h( Q' [" V( m WinGetText, full_path, A
9 B$ t' V8 E; M; y x7 @" r2 ] ; Split on newline (`n)
4 F& B# x7 V* A( p9 T; Q: D StringSplit, word_array, full_path, `n$ z# ? d& }5 w% u% M X# W4 b+ w$ G
; Take the first element from the array
: p; ~& T+ Z) t4 \# r full_path = %word_array1%, v! t& L5 N" k+ ?2 [# I
; strip to bare address# R: K. h3 }( N, t
full_path := RegExReplace(full_path, “地址: “, “”)5 ?! d" f- X% M/ Q7 J4 K+ Y
; Just in case – remove all carriage returns (`r)/ C; x% x6 k8 G7 e
StringReplace, full_path, full_path, `r, , all
6 d6 a6 R5 }7 Z) x6 H0 n X& B IfInString full_path, \
4 i9 Z0 D. J0 j3 f7 [$ d s* Z) r; z {4 T: K+ t0 a/ u6 U
Run, cmd /K cd /D “%full_path%”$ Y- B) i* |: ^1 E) @6 w' j
}/ h. Z' Y4 x; o5 K% `$ i8 _" V
else
! L8 D6 Q+ [) V2 e {
3 l. ^8 r9 Y. o# C. o' Z; B Run, cmd /K cd /D “C:\ ”
/ w9 B7 S: f$ d) M7 b }/ z2 ~7 \6 b7 u0 [5 S1 O& K
}
* [: P2 ]( ` q/ l L3 | @ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ P( k+ n& }9 ^ {* W 这段小代码肯能有两个你需要修改的地方
R R& y; k$ m 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# ^' }+ d" w$ ^& B
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
# L g8 J/ ?0 @4 `" n |