此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
6 O- c$ J; N0 b* i2 ^! _ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。; C" F7 A5 G4 ]' Y; c
方式一:% E( e" u* i. _9 |- C9 u1 _* L
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 w$ m* X L2 p$ }; J* P
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和, M6 d# O" X! z
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 g$ q+ {2 g6 @! U( `1 t8 n! N 方式二:
5 Z' B+ _: b, m5 z! c$ T 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! Y1 o+ Q# @8 C( o- c
SetTitleMatchMode RegEx/ C# `( W; h9 V3 g# Q
return" ?! D( H! B% ^) O) v& P
; Stuff to do when Windows Explorer is open
) a8 R: \, f/ X4 @- ?1 n ;; K- ?5 h) |7 S8 Q
#IfWinActive ahk_class ExploreWClass|CabinetWClass
1 X5 x- q2 P9 Q- }, ? ; open ‘cmd’ in the current directory* c5 h2 }* i; m& c
;* C6 F# K6 Q1 ?2 A' Q* }
#c::
5 p; i& T. J3 h OpenCmdInCurrent()- u' b! M/ l/ N! P; T+ I D) l
return. N! f7 F* h5 {9 W2 x
#IfWinActive2 |9 H4 j/ L0 u* g5 I; P
; Opens the command shell ‘cmd’ in the directory browsed in Explorer., f" @1 V' D6 L; N4 X7 \
; Note: expecting to be run when the active window is Explorer.4 O6 v; m9 A: m/ u Q0 m' E
;& Y" T- K3 M' L3 b
OpenCmdInCurrent()& P. v% G' X1 e% z9 v6 e$ K/ V
{5 b9 ]4 u9 y; m/ L: L+ P9 t6 E
; This is required to get the full path of the file from the address bar0 g1 }7 J! K. p- L) N+ j( Q. e
WinGetText, full_path, A
/ d: M$ d7 K) T6 n ; Split on newline (`n)$ k# l9 |7 A& Y
StringSplit, word_array, full_path, `n
1 x- F( e5 r7 C7 T0 R2 V# A; f ; Take the first element from the array
1 ?, }' R }3 C; g& b4 q full_path = %word_array1%5 O, v# W! q6 ^: j$ a2 d. L
; strip to bare address% U" A6 |$ A, f. R* b+ v; z. P- a
full_path := RegExReplace(full_path, “地址: “, “”)/ U; I: }: v/ ?- `7 b2 X! Y
; Just in case – remove all carriage returns (`r)9 F. G( K" t7 ^- q' e7 |% V5 \
StringReplace, full_path, full_path, `r, , all
, ?! ^- h3 ^1 O5 y, ?2 S. T IfInString full_path, \) @% T! R C) [% n6 {" y
{
, b" i( f7 u. v8 I {* f3 ] Run, cmd /K cd /D “%full_path%”# z/ F' X6 H2 A; `- ^7 |
}8 R. s$ z5 q% w; C% s7 p5 S, W5 Q
else0 `1 @) h4 u/ v g" s, t# G* n6 f
{* r( u/ w0 F, n
Run, cmd /K cd /D “C:\ ”0 n$ n: ~/ s( W6 C& H+ n$ ?3 I
}1 A) ~* p+ g9 _! I
}- D. ?7 n- o4 V, x7 k
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& J# O. J1 y2 |8 H" [( g3 G6 E/ i
这段小代码肯能有两个你需要修改的地方
6 ?7 l6 E& p& G3 ~ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
: O1 f3 \" r$ ^0 Q3 S2 h) M 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 |* a( ]3 Y7 Y- y( x# ]( [) f
|