此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
@4 u! m$ I9 L# J$ A* Z 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 @8 o% P. a, k5 ^% X4 @
方式一:
. O# z8 J5 G! P: q! v 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,5 C+ O$ ^, }$ [/ U$ z# ~1 @
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和& f: c! J8 g5 x' {5 V) I3 @
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。& v$ K1 h+ O/ V+ V+ c
方式二:3 |6 d2 ?) V3 V7 c2 r& t) o% M4 Y6 a
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 e8 ~! ]- v- I/ H
SetTitleMatchMode RegEx
! P! c( @, {: X3 W8 T: H return6 Y4 P0 n; X% H+ u( ?1 S
; Stuff to do when Windows Explorer is open9 @/ t1 n* Z+ N1 K
;) N: P; ?! | t
#IfWinActive ahk_class ExploreWClass|CabinetWClass
9 m$ t6 J7 k) O7 F8 J' ^ ; open ‘cmd’ in the current directory
' [. g0 I$ @* x ;$ P3 f( c" K4 x
#c::" G8 O, h# e; R5 \+ q' x
OpenCmdInCurrent()
" {9 @4 \4 W) D4 G+ b, m6 C return: w) H1 D9 ~' w
#IfWinActive# q2 R% E6 S! o! h
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' z5 d9 V, `" I4 V) F1 F
; Note: expecting to be run when the active window is Explorer.- W" @* d0 m+ m1 P/ U( n, V1 ?
;
7 ^# P# S* u% e* [( V" ?0 u3 e OpenCmdInCurrent()
& o$ ]0 o ^3 g {
+ o8 F N+ Z' T( l; o! i ; This is required to get the full path of the file from the address bar
4 P) r' @7 ?5 Q# i WinGetText, full_path, A
% \+ C+ Y! q9 Q; P ; Split on newline (`n)
# W1 m9 u9 f7 a StringSplit, word_array, full_path, `n
6 j( e8 @* Q6 I ; Take the first element from the array
* c/ k5 ]7 ], i/ N; V& ]( n full_path = %word_array1%
: D' R' U+ c/ r( T6 t2 N ; strip to bare address+ V8 o' {7 e+ y2 L
full_path := RegExReplace(full_path, “地址: “, “”)
) i7 m# W' p5 K! L5 r ; Just in case – remove all carriage returns (`r), z+ q6 d/ g q% ]3 u: |' D
StringReplace, full_path, full_path, `r, , all
" n" B7 a/ z0 I- ~! W IfInString full_path, \2 E4 p: \) C; t0 R5 {- L
{) y- j- P. W1 d+ o
Run, cmd /K cd /D “%full_path%”4 X, X% _. d1 G7 r
}
2 U& e8 Y! r6 ^. A/ D else
( D/ h; Y+ q- E2 T* s" B {1 A1 g$ J; t7 Y, }) s
Run, cmd /K cd /D “C:\ ”) A/ {+ Z+ H8 S
}
& z- R, o1 p9 O4 P }$ ]' y2 l- A# s, ^) |5 t& l& {
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" n3 ^. g% j) R- [$ q, O1 r
这段小代码肯能有两个你需要修改的地方
/ E3 b. ]% [5 j* w. y 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键- `% p6 ]" {4 _
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 Z2 \7 R8 |2 P/ | |