此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 p' H- u- c2 q0 B
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。- X2 F( ? r) z* D B& g
方式一:
- n8 d% B* V7 s7 D 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,# z7 y6 O9 U' L* H; G
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, N& Q, J1 c% e HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" e6 l5 i: |7 G x0 n# x
方式二:
* R* P: C7 F( C4 |8 g0 T( F 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
0 {# R2 h$ @/ R4 T( M m SetTitleMatchMode RegEx& ^( ~5 X; ^, e5 P4 o
return
0 Y3 Z3 H1 b, \$ I& |. M ; Stuff to do when Windows Explorer is open6 p* `. o& t9 U0 M$ c9 S, i. b
;
9 _- } M( ?0 k #IfWinActive ahk_class ExploreWClass|CabinetWClass
% \6 C W9 p* I0 I9 h L ; open ‘cmd’ in the current directory- F5 R% N* C" j
;* U' N* ^+ ^" j; H( B E7 M9 t
#c::
) g6 S$ _$ R7 y2 ^' ~( z! g OpenCmdInCurrent(), q7 { |% ?- ~$ t& r
return
p }# E5 U% a/ t #IfWinActive
# \5 l6 L5 i6 A7 o ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.& ?, ], k" q# U$ Z) g# ]
; Note: expecting to be run when the active window is Explorer.
) f: R1 C7 X$ D4 n& G% h ;
+ M h5 A# q' c0 p+ U% K/ h7 l1 i OpenCmdInCurrent(); A w6 _+ m6 ?, F _) a2 m
{) ]( G7 b3 ]6 N+ I6 u$ i) d R$ |
; This is required to get the full path of the file from the address bar
$ _+ ?3 N" A. L. K WinGetText, full_path, A* H. m6 G( E5 L! y
; Split on newline (`n)* o8 n" c; E/ W3 f( X% @
StringSplit, word_array, full_path, `n
/ y6 k6 @% p+ r2 _# L% X( S- o ; Take the first element from the array
C. r" H7 P$ y1 Z9 _7 g& Z3 l( P full_path = %word_array1%
* p0 _1 V0 m$ Q2 P ; strip to bare address- F. Q# K8 t9 K1 z! p
full_path := RegExReplace(full_path, “地址: “, “”)
3 K& a, F, z% @8 B ; Just in case – remove all carriage returns (`r)" k. ^$ ]2 f! c2 {" G0 `
StringReplace, full_path, full_path, `r, , all
: W+ i, p. @! ~& ` IfInString full_path, \
3 E' M2 } Z7 u7 Q) r6 G9 r {% C% Q8 }" h$ F
Run, cmd /K cd /D “%full_path%”4 v. B0 H* E8 I" U9 F
}; A! j7 v1 r) A
else
9 l8 A# J4 \/ ?# x f' r3 r( a {* l6 n9 p) l5 s+ k; ^/ O
Run, cmd /K cd /D “C:\ ”
, u7 w! I2 `6 l0 o) K }8 G9 M1 v% X# L* P- w: X
}
% T: b' \6 r% u, l# m 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 h- K' L6 x; T5 x" O' Z: }: f 这段小代码肯能有两个你需要修改的地方
! ]/ j# A a* @9 x6 D) H 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
2 X' @1 I- Z+ f0 I/ J( V4 E 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ R5 g4 j5 P9 w+ @ |, B, E b6 G |