此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。3 i; M7 I, s( k
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% F& K3 T8 M R6 y9 v4 U" O7 u
方式一:
# b0 H1 _# w. Z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
' A# C1 c' k- f! [: b 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 i3 ]& Y( Q4 W HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 i- b4 ~5 O; G
方式二:
, K4 j/ J# ^" {9 m& p5 @ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. @. m) G( L' z3 ~# Z0 Q7 C
SetTitleMatchMode RegEx$ s; Z8 F8 {, |+ m0 _2 x
return8 S9 }5 u) Y8 _. y8 d0 |
; Stuff to do when Windows Explorer is open
% ]! D! d. Y( B; C ;8 k; {. k+ b! I; g! y7 R. Y* |* P
#IfWinActive ahk_class ExploreWClass|CabinetWClass: t! t1 B/ N5 v, M9 J4 j$ I9 @
; open ‘cmd’ in the current directory: B# X( h5 i! E* z. w8 E( ]+ ]
;; J- a4 ]: N( l6 }+ e# n( V3 ?( {9 v
#c::
6 @+ ] a( m* n OpenCmdInCurrent()
) `* h3 p& Y9 C% n6 m% m* ?% q return; N) i' l' b2 K9 F7 Y% Z$ M
#IfWinActive
5 w% ?9 M( x8 ] ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.- Y$ ^+ ^4 Z4 Z1 r2 y3 c
; Note: expecting to be run when the active window is Explorer.# E" j; }. R( l# w7 r
;% d$ o! k4 t ]: @6 e' s+ B& S
OpenCmdInCurrent()9 C9 y3 D2 G0 m- r( }
{
8 y% z) ~8 i6 p+ j# F) j ; This is required to get the full path of the file from the address bar/ w K6 n, g; c# Z
WinGetText, full_path, A0 Q" x Z, H5 L- r
; Split on newline (`n)! z- V4 _# N! l& g* Z: C
StringSplit, word_array, full_path, `n
, Q g; a' k# n: C, n% l. l- R ; Take the first element from the array
" Y$ F9 \" S1 Q. j) T full_path = %word_array1%
6 A8 n6 [( P! l5 q+ b! h ; strip to bare address% c9 `6 R7 U0 v& d, O% J
full_path := RegExReplace(full_path, “地址: “, “”)
3 t, O; C* F, o6 @/ b ; Just in case – remove all carriage returns (`r)" X$ y, E! X, I
StringReplace, full_path, full_path, `r, , all
( {0 K8 h# i: r IfInString full_path, \
2 v2 |0 M0 L8 e# I+ F9 p$ J {
/ Y2 \6 |6 r4 L; A0 j: o Run, cmd /K cd /D “%full_path%”" I3 T/ o) _" s _/ s
}% ?0 n' F: O; u, m# W- {4 \
else
0 c& L2 s; M3 s2 N# y$ S {
! I5 ~) Q& h2 Z/ e% h) G Run, cmd /K cd /D “C:\ ”
' p5 I- f# N9 n: S- n: z+ T }
8 a4 F4 P! `2 C4 W/ n; h }
+ z7 A8 G, n5 e$ [+ p 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
9 Z. ?' z- h; o% d+ c1 \ 这段小代码肯能有两个你需要修改的地方" T5 q5 p! o7 z: N! U6 L
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键, R! a m: C7 i6 R7 |5 U1 z
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. o. n7 C0 U# ]8 c r: Y0 A
|