此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 `3 v4 Y2 T, {* A- g
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 Z# u8 @# D0 \; f) F, y8 N 方式一:
7 e& d7 y* t( O+ q 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* W& Y' O2 ]0 G4 P$ I
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
J! b; M% }! m$ I: j- @; {, A HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
- R1 i$ {: D7 h5 @0 q5 {) a 方式二:
6 u. w% B6 Q s, K 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:/ Z, M4 B/ D: R
SetTitleMatchMode RegEx$ I" c7 X; D' M- |9 J8 P- B2 D
return) N. j G$ b- d: y5 u+ J# p
; Stuff to do when Windows Explorer is open% ~8 c- G; ?+ J; k4 U4 x
;. F9 n( z; \ t6 k8 G2 D
#IfWinActive ahk_class ExploreWClass|CabinetWClass" G$ o1 v+ Q8 x" ^ m
; open ‘cmd’ in the current directory2 `4 G' `& X3 J+ U, b c
;4 K# L7 Y7 Z4 l4 k
#c::
. L! r# I! n/ _) L OpenCmdInCurrent()
/ O- }1 S' N2 q1 P G& F return
* p7 z% U* V- S1 l5 `" x) p% ^ #IfWinActive( ?: u- _( G7 [& |) u% `
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' f3 O$ D4 ^' E; ` b5 s" V6 l
; Note: expecting to be run when the active window is Explorer.
) X% D- O: p' M, x) G9 X ;( \; O7 J% e1 Y
OpenCmdInCurrent()
' |8 C: C. S# ? H& Z' w# i {
% k0 ^. c! V, p' `) _ ; This is required to get the full path of the file from the address bar
3 p7 x$ `# c. W WinGetText, full_path, A9 l2 E7 u: ^" t! l
; Split on newline (`n)
8 g0 e$ t9 L @3 k. Y- @ StringSplit, word_array, full_path, `n
; \# M* X( Q2 ]* x% m" p4 d ; Take the first element from the array
/ g8 f& }* s' S: X, ~ full_path = %word_array1%8 F2 v, t* F. j5 ~: j
; strip to bare address
2 t$ H( ?% O8 ^ full_path := RegExReplace(full_path, “地址: “, “”)) q, V C9 z; V% V; i
; Just in case – remove all carriage returns (`r)* O& J7 ?6 u( X" s1 h: U
StringReplace, full_path, full_path, `r, , all; i. R0 {; x1 \5 |, p# e9 h
IfInString full_path, \1 m; E: M& D1 w. Q7 ?( d6 Q+ h/ R
{
; l% ?8 q4 b* B+ o, m0 T Run, cmd /K cd /D “%full_path%”
* J4 t) l. H# E3 ?( b }, g, Y: }+ J; ^- T! e5 B" B
else( b: l* T) y- s3 @ @
{4 t8 ~" \; z! M9 A$ P% E" c; t
Run, cmd /K cd /D “C:\ ”
4 z2 S; T( s6 x/ P6 l) ]$ \4 D1 X( b }
" b! [6 P; r, d |. r }& `" J% y* d% L4 ~
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 s q- ~) j4 Y/ \$ f6 S
这段小代码肯能有两个你需要修改的地方
) ^, I. t( M5 M' E1 T& m 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 I8 K; J" U3 Y W5 p- b
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
0 D. S! |+ c% {; m y/ l% u0 q |