此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
. e7 P) l4 x( {7 @& s 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
]# g+ o5 p$ X. u2 ^, F4 w 方式一:
' P, a1 D# w4 k) K; k 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 M3 S' X0 K" e( a! `! i+ w
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和4 ?% @3 ^! c3 q+ t( g
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
- _6 E5 T) U6 m) t5 `( t; j 方式二:3 n+ G \# [5 U& s
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
9 {: n, I& C! y ~4 A9 b SetTitleMatchMode RegEx9 m: @" V7 ?" l3 L1 C9 g
return" E/ o. \ i1 y+ _, ]" M* e7 w% V
; Stuff to do when Windows Explorer is open
1 E# @& c5 [9 Z, z( `% T9 d ;
) w4 Z2 {' }& A1 j+ i+ H #IfWinActive ahk_class ExploreWClass|CabinetWClass
+ J/ `/ I; `/ W, Q1 H2 R, | ; open ‘cmd’ in the current directory
7 D4 y* V. x- |% P w ;. p6 C: I$ E+ t5 n% W
#c::- n" ^9 B/ @: Z$ j: c, U2 l* N
OpenCmdInCurrent()
4 ]5 Y5 \1 ^1 U; J9 y6 e return% b$ O% l; M. h4 q# M! K
#IfWinActive
9 F) j' l4 x/ w$ _% K ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 a% l, f, o# l/ b, h ; Note: expecting to be run when the active window is Explorer.
0 p7 q6 k2 W0 W) \! Z2 @ ;
( Q% i. v& K! B% ? OpenCmdInCurrent()) c+ B3 v* S6 @4 G/ n2 {" o
{
4 C; H$ R) y( {5 w ; This is required to get the full path of the file from the address bar
( E8 C+ ` T1 v WinGetText, full_path, A
0 U5 F5 b2 q. l( }- p1 D! u5 c" y ; Split on newline (`n)
2 l3 M) @; }( c: ]" f. _. { StringSplit, word_array, full_path, `n) N1 B/ x4 o+ B: t+ f
; Take the first element from the array
: j& _6 K$ n! y4 u4 ^6 j, c full_path = %word_array1%; ]9 t, D3 H7 q' [9 f( H1 n
; strip to bare address" b: l6 ^6 g& j# r
full_path := RegExReplace(full_path, “地址: “, “”)& e) r& w" ~3 J
; Just in case – remove all carriage returns (`r) H2 z' [5 B' v! z! X: e# b
StringReplace, full_path, full_path, `r, , all! f* H5 M- i5 Z. z, c8 y
IfInString full_path, \* D- C- ~" D, ~/ y- G( r# t8 B
{
' \4 J/ s9 F8 `. b+ K0 t) f1 B Run, cmd /K cd /D “%full_path%”
4 K( h2 a+ i4 Z2 i8 N }
0 D; x: O2 }( T8 k6 L) `+ t t6 K else
+ o/ r4 [9 r- G( L+ J, h0 x/ y7 Q {
B" R+ q. T- G4 n& } Run, cmd /K cd /D “C:\ ”3 P6 [, f3 B q1 L, A* Z G9 W1 H
}. L" t6 M, C6 w
}
! c: m$ n8 U6 N+ M" d; {# H. Y 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 d9 I9 z7 _5 D9 e: {1 p 这段小代码肯能有两个你需要修改的地方
9 p9 @8 I" Z: x6 {; R 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
A+ E4 q' C% ~: J, \, a! W 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
% t' j' R& O" T: Z+ L. I8 S; _ |