此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
. B: L+ w/ @' \# K+ K3 I4 S 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。# C A' Y% e& V; A; n- ~
方式一:+ O8 g0 o1 z, @* `$ Q" a1 q' P
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,7 }& y6 r+ A' T
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) f& z6 b. t$ b
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) Q4 l- N3 \" `0 f# ?9 y; O
方式二:; G u- C6 ~: h7 w; R2 m
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
; _# O" g# N( B7 P. ` SetTitleMatchMode RegEx
9 ?: B0 |9 R1 c3 p: @ return* P( _; }" e {/ ?0 C
; Stuff to do when Windows Explorer is open
" ~" K2 d# w( U. G% w, H: L ;
3 y/ b, E: V, f9 r #IfWinActive ahk_class ExploreWClass|CabinetWClass) k% }0 @4 \, Q2 }! Q: U
; open ‘cmd’ in the current directory5 E3 |8 u- O5 w+ J/ H* Y. T- L: g6 v
;
4 b$ I0 m8 e5 e" I- o& E2 @ #c::" @" b7 G* H6 o) t/ B1 [
OpenCmdInCurrent()' [( L4 n) Q7 y0 q7 e v4 q
return
# q9 a$ x/ S% J7 e2 ? #IfWinActive3 d( E& ]. i) a$ h8 z/ C, q
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' e U3 n+ T, h8 l, s6 L: n8 ] ; Note: expecting to be run when the active window is Explorer.5 `9 _# q1 B5 @8 C5 J) v# h
;
O, I% I! I$ o2 T. Y OpenCmdInCurrent()
' m/ M8 g- @* a. a; O {
% V2 {* n `0 v* c+ c+ I- {) | ; This is required to get the full path of the file from the address bar
/ _6 U ]: o# q9 A9 l- }1 H5 P WinGetText, full_path, A
0 r' @' c! L6 C. s4 } ; Split on newline (`n)* `% R! G* }5 k
StringSplit, word_array, full_path, `n
6 V$ q1 }' c8 l! F7 ]5 H# i+ S ; Take the first element from the array8 ^0 g$ g u# D" Z7 \
full_path = %word_array1%5 ?1 {& a0 _7 }/ n/ E' y
; strip to bare address' ~+ k; G$ o6 B( m7 \* e
full_path := RegExReplace(full_path, “地址: “, “”)' A+ s8 p+ @- I& T7 {, L' ?5 m; U
; Just in case – remove all carriage returns (`r), z% K ?# L5 D$ J: Q# T
StringReplace, full_path, full_path, `r, , all
% \! ]7 Q0 I% e" Q IfInString full_path, \
; L0 z d" g3 b- ~ {+ p8 I7 h8 Z7 g# x5 v
Run, cmd /K cd /D “%full_path%”
7 K* q4 A; q0 ]& d* T }* ?& R# y& _- O& C6 `0 \
else# a, w3 `- f+ C. _
{
+ M( d5 B( n2 W Run, cmd /K cd /D “C:\ ”
8 S1 m) ?. }. _2 l$ ?0 [ }
% v2 X" q2 ~ f4 D8 Z% y5 g }
/ Q$ L: x: Y# _ k 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 x. L* j0 B3 @2 ]
这段小代码肯能有两个你需要修改的地方
7 }' A7 }. }3 ]; h 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' v7 `7 p" W- l
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 h& j3 d% ?0 T- q8 c/ \ |