此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 E, C: B w3 @; R
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 Y, p" i; W! z
方式一:
/ q# I& W2 N- D7 u 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,) P) k S, c3 D" f
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 W& p. w" y9 z( l6 \ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 L% T B8 V8 Q
方式二:
9 h5 p0 g* X5 I5 O( H 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( z/ K. Z$ f4 ^3 G8 A" k7 K( V5 b( t SetTitleMatchMode RegEx* a z3 P$ n& m# M
return
$ s! _1 C' F% H& {% E! h ; Stuff to do when Windows Explorer is open! h D& F+ o0 u8 x4 w- q
;) v2 I) o: @0 c' }
#IfWinActive ahk_class ExploreWClass|CabinetWClass. {. F( P8 X$ n7 X% H( |) E" P/ V
; open ‘cmd’ in the current directory1 ]; W) C+ l+ [! L
;
8 B& B& N" l' P7 h #c::
+ v+ W/ V8 L, }$ C7 T9 @( I0 A OpenCmdInCurrent()
- I1 P/ U g$ T* z4 k- j8 @ return5 b# L0 l0 i+ k4 k
#IfWinActive+ Y( a9 s1 K1 @7 z k
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.2 N/ Y# x2 ^) `2 v. q
; Note: expecting to be run when the active window is Explorer. U& [" m" A+ h5 u4 N3 Y7 L, N
;% |* N' W1 D2 l! X
OpenCmdInCurrent()
- c7 v1 ]* P1 O1 T+ `- f# _7 q {" @/ c% s( w! `2 _1 f! x) E9 Q
; This is required to get the full path of the file from the address bar
+ `& E5 ~3 U+ m+ K! x WinGetText, full_path, A, M+ i) s0 w1 D6 t: X
; Split on newline (`n)
: G- o- A @ G StringSplit, word_array, full_path, `n9 u/ c Y; p, x
; Take the first element from the array
! k, z+ ~$ L8 Z9 [ full_path = %word_array1%
# @, a0 W$ h' @! ^9 e ; strip to bare address
7 M4 c2 S7 A+ w' h full_path := RegExReplace(full_path, “地址: “, “”)
C6 p& f. w) V" H/ S5 l ; Just in case – remove all carriage returns (`r)
& E0 D3 n- g. O7 d, s0 g StringReplace, full_path, full_path, `r, , all7 T) T7 V9 K2 |" c9 x
IfInString full_path, \
5 z9 y* o6 _% u; ] {# ?5 D, h: j5 s3 X, w
Run, cmd /K cd /D “%full_path%”
& f% Z( M, x6 y- O& c }+ A2 e3 I( A& Y- \
else
' M. }, d0 S! X+ |% N! d7 N/ u8 e% w* F {
% f& `) z: i8 Y. r! |3 v Run, cmd /K cd /D “C:\ ”
' I9 d) u! S; ` s }4 Q U. I5 D% G; R# l% i! C
}3 i ?3 [- o, C9 q0 Q) B. k6 N0 s
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
! ~+ Z f) a9 f8 _3 F% w 这段小代码肯能有两个你需要修改的地方
# {6 t$ t* M$ s4 t& r; w4 o7 n 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
y, B+ I( N: |8 z) ^ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “& ]' A: `. G* e& }& q: K0 b# j
|