此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。! c5 k6 ^; X" t. ]9 L1 Y$ X2 F$ ^
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! E T; @) s U+ a3 s+ g! v8 ?
方式一:1 Q. e9 h5 A$ j# e0 e
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ b5 E% k: m I0 G4 o8 n
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和1 ~* u) y9 S0 U" Q( E- `1 X
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! |0 T- W, d" d5 ^$ E 方式二:
3 b+ r( n. A3 {' S; d ^& D 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" @: [- T! F) y6 q$ L SetTitleMatchMode RegEx0 R5 \! r1 f/ j
return
3 S* D# p3 s( J2 E, y ; Stuff to do when Windows Explorer is open- M9 L% m' T+ W: l$ n# \5 ]
;+ Q- u% u' d2 Y7 E& q$ p
#IfWinActive ahk_class ExploreWClass|CabinetWClass; J$ A! E- B- x9 ~4 _' r h6 |# y
; open ‘cmd’ in the current directory
8 o1 d0 V- N$ L' c9 ~0 |8 M ;
9 s0 L; W" k" s h. } #c::
) w5 Z' Q9 k5 z- i OpenCmdInCurrent()
# q8 @5 \% j$ y return
M) e; F% B/ U9 o- p/ ^- Z #IfWinActive$ ~+ `3 r; u. { X# Y0 l
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' x2 z- T. r! o
; Note: expecting to be run when the active window is Explorer.4 {" } i4 m- p i
;
" t; D! k2 d" g2 e OpenCmdInCurrent()
3 I2 q( Q$ Q, y: q6 X( i( [ {( u+ u @& S- P
; This is required to get the full path of the file from the address bar
( G/ {% |# `/ M" } WinGetText, full_path, A
" E/ d0 J; ]# L) @+ G: X. f' t1 t ; Split on newline (`n)( X7 h8 {, D2 i$ o8 ^7 F
StringSplit, word_array, full_path, `n8 W. o9 a6 f; ? [2 g; [5 n- j
; Take the first element from the array
; m, _8 S( ?( m full_path = %word_array1%% i5 q; ^6 a/ S, S* O( h$ U
; strip to bare address
7 p3 I+ }5 d) c& }. O h full_path := RegExReplace(full_path, “地址: “, “”)" [' c& d: ^* U' s0 I5 I# Z
; Just in case – remove all carriage returns (`r)0 \+ N* h9 @* c, ~& S
StringReplace, full_path, full_path, `r, , all+ M% J) Y) C+ u/ e) Y
IfInString full_path, \
8 E% R. \ D' t% Z3 ?- l {% P% ^% u5 E; B7 U; F3 _, p R' s& d0 F
Run, cmd /K cd /D “%full_path%”
5 t' }, F0 _+ X }! }) b! H* [, A( s: T
else5 T8 x6 o$ p1 O
{* j4 O# N1 L+ ^1 g! T w+ Z }
Run, cmd /K cd /D “C:\ ”
9 c" t; l. t* m9 z- _- Z }. o* h' G& @: B5 M; V: D! ?
}( y) j) B/ Z" z0 B
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 s, G+ O* i" ?7 h, U- Z 这段小代码肯能有两个你需要修改的地方
7 o3 {% F! Z$ K9 _' n/ a7 h 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
F: D# E2 O. x) _7 C2 G 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “# ?% m& |9 ]7 {+ c! J
|