此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
. N5 V' v) i. X# W" P 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* x( Q. Q7 A7 X; B# ~
方式一:8 ^' R' i; c b
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 k; S$ u2 m8 |2 ?# z# x/ Y9 s
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) O' ? N; C/ D3 A! k
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 N5 ~1 ?( w6 O- D4 }4 n! q
方式二:: u( H) p9 X. V* D8 M! M/ M" B: s
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, W5 q' X2 R" ~# a+ K
SetTitleMatchMode RegEx
" u" _2 ?! a' ]' Y4 Z+ f" y0 T return
' }: L: Y6 o$ t ; Stuff to do when Windows Explorer is open: u! s& e2 U/ }7 K5 T1 f7 y
;
2 ~- ]0 i' a4 U) ?, [' t/ W; W #IfWinActive ahk_class ExploreWClass|CabinetWClass! F* V0 p+ D# @7 d
; open ‘cmd’ in the current directory% Y0 a1 _, @' E8 t% Q* p$ t @
;
& k( n0 Y" m3 l' Y& u5 O #c::/ t) l1 z. w: }, c) u7 ~
OpenCmdInCurrent()
f' G3 Y& C! z" \: S return
! A' q3 r2 u, M #IfWinActive
* o% E5 T! k* D- _; t- v ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.6 H# _4 |4 D9 M: w# J! G4 S
; Note: expecting to be run when the active window is Explorer.+ {* d8 i: w! n+ S
;
: e8 S# H9 S" N G$ k F# a c OpenCmdInCurrent()* y2 d, _8 c1 m& V7 w
{6 ^! x5 Q! n8 T3 a% {, U( c
; This is required to get the full path of the file from the address bar& e) K; o/ ^) c' p4 h
WinGetText, full_path, A; k6 I; ^7 h9 F; [& g
; Split on newline (`n)& F' a6 b- w* t6 Y, r
StringSplit, word_array, full_path, `n' i% |" h6 r3 w8 E" l3 O @" O, U7 T
; Take the first element from the array1 T/ g- }$ h8 `0 N2 P7 }1 O+ m
full_path = %word_array1%
- P J: F6 A3 T. M& g& |8 G ; strip to bare address
- [# o4 \! Q" [0 [ full_path := RegExReplace(full_path, “地址: “, “”)
% c0 a' Z, L; O/ E% Z ; Just in case – remove all carriage returns (`r)
0 e3 L- x O, P) `1 ]3 | StringReplace, full_path, full_path, `r, , all
# _5 x) h) Q$ Y IfInString full_path, \/ T4 `3 G, U) [% f a
{$ H3 t" X: z9 l
Run, cmd /K cd /D “%full_path%”8 H$ k* V) u6 d4 u/ {% O
}2 B4 w4 U+ d, x Z w$ a
else
. L/ O0 K* b+ u( q {* h. ~8 J0 z% |3 s+ Z; }$ k$ E
Run, cmd /K cd /D “C:\ ”
% f! d4 h* z6 S. l }3 N7 I; K- L. ~' H9 Y- k
}
* R' s2 D5 Q5 Y' ~9 z/ ] 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 V+ H% x. B5 Y3 x' L, i" E( x 这段小代码肯能有两个你需要修改的地方1 E" ?8 U" ?9 ~& ~8 i- z/ x
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) _4 }: p2 |& H" {8 }( q% g' T 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “" [# _! i \3 t0 W f4 S: [6 p# L# n
|