此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 K9 o6 Y, E5 V" R! U9 H) Z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 Z3 A1 X4 `& q! b6 {$ U
方式一:
0 L* L$ U4 X, ^2 H 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- Z% e y& k1 Y8 _; R
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
' t# z6 v0 y$ U1 b) ^% d) z HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 l2 [5 ^- ~" Y. f, s" d \! v" n H
方式二:
% @0 Z5 A4 m, z" ^2 j( k 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" U6 c$ M% l! h2 C9 o! K
SetTitleMatchMode RegEx
8 w3 o6 {8 @ _) i return& L2 D5 L) a: `, ^2 O9 b
; Stuff to do when Windows Explorer is open9 y6 c+ {. d9 G
;" n; T& U) Z$ V4 E8 B5 b; |
#IfWinActive ahk_class ExploreWClass|CabinetWClass
% s* E0 n- q( y1 r6 g2 P, ? ; open ‘cmd’ in the current directory
" c6 q& U% F; U9 I) z ;
' c6 y) H$ [/ b$ ] #c::% G6 _& l8 C/ O0 P$ X
OpenCmdInCurrent()
. L# [ ^4 `2 L; I, j6 B return/ L' Y6 O: s8 f
#IfWinActive
7 f! v) v$ @( Q$ z& U ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( e0 i9 B& P/ f+ h9 F: s
; Note: expecting to be run when the active window is Explorer.* Q) Z8 ]8 t4 E
;
- D8 ~9 e7 U3 V3 U* s OpenCmdInCurrent() z5 _0 ]/ O, P) T. P& c+ c+ {
{
' ^6 l* T% F% Y. {4 | ; This is required to get the full path of the file from the address bar
2 ~& T6 l# X( c" `* \ WinGetText, full_path, A
+ p1 G0 V6 |1 K) d8 v6 p- S2 v. G' A ; Split on newline (`n)2 t: P! K+ c4 E1 r: M( K! [9 y
StringSplit, word_array, full_path, `n
' O$ W$ F/ D) X ; Take the first element from the array# H. N. o$ A3 o8 x
full_path = %word_array1%* t7 w4 v2 m6 r" y( ~7 ?
; strip to bare address9 K/ W0 W- p. Q p+ g9 A0 E* e' ?
full_path := RegExReplace(full_path, “地址: “, “”)
6 k2 \$ v- \$ V8 e! h; E6 a ]- X1 o ; Just in case – remove all carriage returns (`r)
* g0 v. a3 T9 d# L8 }$ ~$ \8 I G1 \ StringReplace, full_path, full_path, `r, , all& M4 o1 x: ?; ]0 i2 p
IfInString full_path, \) A& m/ n+ [9 r' P2 [" ~' L
{
0 C6 s1 j j: L D6 P8 j5 Q C Run, cmd /K cd /D “%full_path%”! l. w5 H8 u+ L) e+ K8 R# t
}0 h& p. i3 _0 k
else
! a2 X; x$ P1 N9 G& J {
C" w: U) v# @' H Run, cmd /K cd /D “C:\ ”! m. ?( e$ C. F$ J' V" A
}* l0 A3 D& P3 m5 g" m0 U* s- I* P
}
8 ]2 X7 [! v- W9 r4 Z8 Z. _* i 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。; G6 R) t: C% a# X! i
这段小代码肯能有两个你需要修改的地方
2 T* v- s9 x9 ^3 ~ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键% Z, ~ r1 J1 O5 {0 Q
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
# C7 {3 w! l6 j |