此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' [* y, U9 ^; ^ Y! L+ v. Z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
& F- g- H" R- w i 方式一:
$ t; O; E( J6 j( r0 }$ A7 l 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
. c6 u' k) k& W: m 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和6 F7 V/ [+ y1 B2 A
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 l% x: _6 ?) r* L! {+ @+ J" S' G' W6 [
方式二:
1 F$ Q* S6 U& h" }6 C7 M6 r 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:$ z0 u% D% A0 x0 G( G% M0 J
SetTitleMatchMode RegEx+ I4 ?7 H ^ }& G8 w+ N
return
. Z6 l1 m4 z6 c ; Stuff to do when Windows Explorer is open# d% ?' U) u* M# g
;$ k6 J0 A0 k# b+ [. H
#IfWinActive ahk_class ExploreWClass|CabinetWClass6 W0 I4 n) M# B' u/ G
; open ‘cmd’ in the current directory! A, }( @9 J3 x5 K; i' Z/ q9 h& ?
;
4 M! l+ f$ V4 k1 z+ a! R #c::' M% [! r" P1 B. S( R% T9 G' `. H5 N
OpenCmdInCurrent()/ s4 \, M$ E3 u: X
return
- H* Q: Y% @) {* N* Z y #IfWinActive; |$ F5 j3 K" P- K1 K
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: e+ a" } Q3 |' J9 Y# r+ X
; Note: expecting to be run when the active window is Explorer.
4 B, v$ \# X0 Z- c9 H/ {" j5 G ;
- E/ r/ D( S7 X2 t% R OpenCmdInCurrent()5 F' ]5 r" n+ J
{
( ?4 {5 X6 h" ?/ j+ T ~ ; This is required to get the full path of the file from the address bar% q+ @; }1 v+ q" p3 S% Y y
WinGetText, full_path, A
" W0 e" N! Z9 r5 O3 a8 K+ E) p; ? ; Split on newline (`n)8 M! D; O* p. h) Y, o' l
StringSplit, word_array, full_path, `n5 N% ^ q) z0 ?# u2 H) r, S( h& T
; Take the first element from the array
S+ d4 C( x7 Y) S! u* d2 U full_path = %word_array1%0 _1 |# N$ D6 f$ \$ ^) @% {
; strip to bare address2 U) `5 F4 K, J' Q6 {
full_path := RegExReplace(full_path, “地址: “, “”)3 m; i$ Y; P9 x' D* o
; Just in case – remove all carriage returns (`r)4 t$ e& t1 o# w0 n
StringReplace, full_path, full_path, `r, , all
0 q! ^) V& q8 F" a% ~; A IfInString full_path, \
" d/ D& C. Y1 J {- l+ Z# \$ Y' w" L% Q
Run, cmd /K cd /D “%full_path%”9 X1 v) ~) A. m* {8 ^$ |
}. B- R# _" q0 A; @$ o2 k6 K
else
6 W d- M8 |2 W" S { S/ K9 u, L+ a& e1 w
Run, cmd /K cd /D “C:\ ”
1 W: ^( U4 h" o- m S }9 e2 H4 {' o1 e( A/ s- l% e
}. u- e$ E( m' x# `! K4 y' Y
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 O( ?0 E1 _9 W1 w8 }/ T
这段小代码肯能有两个你需要修改的地方
: Z7 ]% c( E2 p3 X 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( R# D& C" o/ j3 Q% N 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 r& `% S: u, S# M& V6 E
|