此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' N! U3 q1 p% P( p3 o 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。+ [& j3 U6 ?6 J9 u7 E
方式一:+ J; {0 p7 X/ A& m1 K/ L! {5 f
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,# h+ o8 j8 X/ m2 K
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和% l$ W, C, V& V+ F
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ w' x. `$ C9 G6 n. T: |; o
方式二:' m& D# P- z9 L
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 B: J& {% M3 A# J SetTitleMatchMode RegEx- \% ~ e5 ]5 B5 k
return
4 o0 E8 j2 n _! N' j4 C5 g# Y ; Stuff to do when Windows Explorer is open
. a$ O! B: F" ?# L) { ; R( D! [, Q2 {! H( i
#IfWinActive ahk_class ExploreWClass|CabinetWClass4 Z: i. P* c# {/ e) t+ M4 g0 a
; open ‘cmd’ in the current directory. O8 O1 w( F! Q O
;* p, v/ N7 E T" c
#c::- P8 I2 ~7 J+ {" W% w
OpenCmdInCurrent()
4 c+ q7 o; O0 f# @9 T1 _) l return2 ^! K) C: K! U% s: u
#IfWinActive3 a% ]' Y# c% d
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
5 a: _# C% s2 ~; Q ; Note: expecting to be run when the active window is Explorer.
: c7 Y3 c5 V+ M% ]6 [ ;3 d& I8 m& \! u3 g4 g/ _! ?
OpenCmdInCurrent()
8 s# u) d8 Q9 d% ~( N b0 R, N3 i+ V {2 r+ n* ]4 p: l9 f& n
; This is required to get the full path of the file from the address bar" y" M/ v9 c& O2 t8 D
WinGetText, full_path, A
& x5 c( D1 N1 E6 e; E) z3 a2 G ; Split on newline (`n). W3 C( }. l5 l& f& @
StringSplit, word_array, full_path, `n$ y$ o! X4 M2 v1 X
; Take the first element from the array
% w( a, H e( @2 h3 `' X; O5 E full_path = %word_array1%
9 X) ?* d* A8 d9 C ; strip to bare address
" H1 r7 L0 X& j6 D full_path := RegExReplace(full_path, “地址: “, “”)
3 F3 M1 A" m. z6 H/ ^2 m* k7 z) @ ; Just in case – remove all carriage returns (`r)3 }1 C9 o& u4 _* o. f
StringReplace, full_path, full_path, `r, , all
$ ^+ H0 O4 l. O6 O8 c3 C IfInString full_path, \
+ C- o# _: B8 {; l9 ~; R {. ?+ s9 y. p, q% L. |9 P
Run, cmd /K cd /D “%full_path%”
6 Z: G5 y1 I1 @ }
1 G$ @6 G {: Y" @ else$ B* m2 M! [# ?8 `- s
{! D/ |0 J' U9 [1 ]) v
Run, cmd /K cd /D “C:\ ”
. I$ M( k" s \: {8 h2 L* V! q8 G& b }
2 A6 w8 z% p2 i8 b+ h# C J# X }, J! m0 ?# @5 a+ ]2 j6 c( |, z
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# G% f; o* W7 a4 G 这段小代码肯能有两个你需要修改的地方
3 l: z& c: G3 `6 t3 S 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
4 ~- h& c5 C0 T 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “/ e& O4 K: H n; n* W" ~/ W
|