此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
! C- K# b( ?* l5 y6 x+ I8 W 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, ]% o; L$ s8 F3 V) \1 B; u 方式一:
6 F$ W" P4 A7 S: F! n6 }9 p5 ^ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 o1 s; f& f" F; [- W) f2 D: g
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和, ~( f2 e. ~/ u! Q' R R/ P9 o8 }
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 a' U( k1 L6 {1 V; `
方式二:
0 m& j2 q, E$ S& z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* m6 S2 f+ F4 i! h7 Y- F SetTitleMatchMode RegEx. a) y6 K- l: w/ N U
return! O: t7 T( m; t- u( d: B
; Stuff to do when Windows Explorer is open
( p% x3 q+ X' O \: x ;: ?, X) m# e# O
#IfWinActive ahk_class ExploreWClass|CabinetWClass7 r2 ~$ C+ c* z9 u
; open ‘cmd’ in the current directory0 H1 {: C9 E3 u) @4 O
;9 t! F$ Q& o# i0 A6 O9 e
#c::& a- f/ n% p9 G& M7 b+ x1 F7 S
OpenCmdInCurrent()7 C# {# Y* K+ }) f9 n$ t
return' Y$ B- t1 p7 R9 b7 J( v% t+ q0 U
#IfWinActive
. h6 `5 z u9 { ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: ], Q: R8 \3 |& l* _, v: \ ; Note: expecting to be run when the active window is Explorer.. o, S) Y/ _5 S4 P
;
. r0 O( o! O2 l% ?8 I P0 N OpenCmdInCurrent()
4 J. P t! P' H6 T% h2 q$ u3 d {
3 ?2 E- q! U% J/ A0 E- @2 e ; This is required to get the full path of the file from the address bar
9 w/ U* T4 @8 e0 A1 c- m WinGetText, full_path, A
; w! K5 W. O" \ ; Split on newline (`n)/ Q. [) H9 n3 ?! q: X( J
StringSplit, word_array, full_path, `n
8 Z3 y0 @5 U( n& x, z ; Take the first element from the array
, Q' _1 Z% G4 |/ O! e/ A4 u full_path = %word_array1%, d* t' m" L- o( y
; strip to bare address
3 t u' f1 z* `0 B- T9 K N/ l full_path := RegExReplace(full_path, “地址: “, “”)
/ b. u a% l" ~) m9 a6 n ; Just in case – remove all carriage returns (`r)
$ l" o1 i& h' m0 ^3 l* h# P0 B2 D- X StringReplace, full_path, full_path, `r, , all0 e5 G4 j$ H" H& B! @" ^( u: Y/ Q
IfInString full_path, \
0 g2 z/ d5 t" u' K4 U5 K {' F" B$ d2 x C; }5 @3 o5 E
Run, cmd /K cd /D “%full_path%”+ C. \1 q7 n0 W2 Q" {
}$ a- h6 F3 H2 F+ j, n7 @3 @
else; X- u5 H( N j* ?9 h3 |. b
{
- S: y8 F; M; y2 o Run, cmd /K cd /D “C:\ ”
' L. e& M# f1 K7 \$ x }
& r7 |. D. c( w+ a }
& M! E3 A3 x# ?- Y( ]) D* N 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- v6 r2 |5 P0 B A/ a 这段小代码肯能有两个你需要修改的地方
3 U& A/ L6 X9 u+ B2 b 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
; d' T) t) f4 V/ e1 D. L! H 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; e, {3 j+ \# S6 ]9 A |