此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' e: y% [7 n% {4 l 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 L: Z8 g+ h, {# G- U3 ~ 方式一:
, a% s5 q* [3 f; [; w4 r4 X, Q 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
$ ^ ?5 j; T5 g% p; p | 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! j) G; p3 D* T2 ]
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 d9 f( b3 }: u) }4 C2 H% _: {
方式二: e9 n; Q. G3 n! e( {! ?* u
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 y E2 Q+ U- r- k
SetTitleMatchMode RegEx3 y% }$ K1 w) ~% \: N8 ~
return$ y0 r& z/ x1 V" U
; Stuff to do when Windows Explorer is open
# U$ w( |' h5 G- `# W; U4 a) K ;+ P; M9 [( \4 A3 {+ Q! O# d
#IfWinActive ahk_class ExploreWClass|CabinetWClass8 \% `% z6 t+ [4 E, b( `
; open ‘cmd’ in the current directory
: \& ?" Y" `- m) V& R$ W: S( j9 | ;
+ x* y. a6 h) [/ b #c::0 K$ c+ s4 B; b
OpenCmdInCurrent() P$ P" m4 Z! D3 }' h0 X
return
; H* k% W. x% Y! v. i4 h! t #IfWinActive
! o+ ~1 \8 a& Q/ f4 [- H( S ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.9 E: \; @( @3 W( M7 P0 x
; Note: expecting to be run when the active window is Explorer.' c' O3 ]& b0 X* V/ I, t
;
5 x8 s1 ^' ^$ _9 B# J0 L OpenCmdInCurrent(). @0 J, y6 [2 T! s
{3 e% W9 ?% A5 P
; This is required to get the full path of the file from the address bar
b/ g. V: M" I WinGetText, full_path, A* P' e8 F# x* o7 `( \, G3 k0 m# `: N- r
; Split on newline (`n)
. r" a# O r" P; i5 y" F% L1 j StringSplit, word_array, full_path, `n4 x" ]9 J/ U, P+ E( } P
; Take the first element from the array
0 q& ~( S; E& h/ E; }1 J( x/ K) ` full_path = %word_array1%$ i n1 } }8 }" P8 q3 |
; strip to bare address
, n5 R% Q% N' h full_path := RegExReplace(full_path, “地址: “, “”)
+ v, i) D+ W- R1 F1 ] ; Just in case – remove all carriage returns (`r)3 b0 Y& R( r+ ?. g1 _; J3 I) J
StringReplace, full_path, full_path, `r, , all& H ^ N% w& Q4 e
IfInString full_path, \, }' `* o' Z- H% X' ^3 N8 I
{5 Y0 j: @; P7 n9 ^. d* ^" B0 k9 t7 p
Run, cmd /K cd /D “%full_path%”
7 G" w; K2 B; w }
" c3 T4 E6 ]7 k2 Q. K" m1 J else
$ y* y4 F8 u3 a( _% z+ d0 W {
! p% E2 `" l' b# C$ a' U3 ~ Run, cmd /K cd /D “C:\ ”1 ]& p& `! `, e, \
}
# x* l& A3 k+ E6 h' \& ? }
8 K7 e. O( l# a3 T- T# y# t; ~ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。$ B! `" ^2 z- \0 {: i& m
这段小代码肯能有两个你需要修改的地方! T) y0 H: Y3 z S. e( ^% {; P
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
! K5 f) F2 W$ E 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ o# ?. `( p8 h; A |