此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# F% `# ~- j$ J: T1 e& E
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
) h2 ?+ I* B3 N& W* p1 e) H1 C 方式一:
0 r) [$ [0 t/ {5 ~8 c 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
9 c `5 Z: B4 _& R 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 P+ j( a: {( I! F: h- P
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 W9 Z! O& ]8 ~5 p( \ 方式二:
" X( _4 w- n' F- X 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- f& i) z/ l7 ~5 g6 P: O SetTitleMatchMode RegEx/ H$ [! G+ i% L+ E
return
7 R' C2 a7 J4 K8 N2 S ; Stuff to do when Windows Explorer is open/ [5 ?. \* z/ r E
;
3 p9 Q3 ], a8 N A #IfWinActive ahk_class ExploreWClass|CabinetWClass
; e0 L7 K* o' [$ ^ ; open ‘cmd’ in the current directory
6 K9 [+ R& ^, q* O2 W0 P ;+ z0 T4 `! Y' Y9 J" z
#c::
0 y! \% c, R s: }1 d4 S# `% J OpenCmdInCurrent()
' l( @/ ? d" E' k return% M' g9 m' V# O d. j% A% Y
#IfWinActive. W! L: Q* o+ s M4 D
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.! y) w3 q: ~; Z
; Note: expecting to be run when the active window is Explorer.- [0 @5 s0 e+ y
;
# m1 ^- R, u5 R3 R# L OpenCmdInCurrent()
7 ?' \0 g6 c9 j3 ^' ] {
) z$ {( ]; m7 J5 @* y& J( k: ~# R ; This is required to get the full path of the file from the address bar4 c# n" Z' K. }0 |" l' T0 h
WinGetText, full_path, A0 ?# L* u" q, }# M6 R' Y
; Split on newline (`n): ~4 M6 Z' }8 r0 ]: A
StringSplit, word_array, full_path, `n2 j" {7 h9 `3 R
; Take the first element from the array+ w6 x9 ` Q2 t
full_path = %word_array1%' }* v7 O' M- @" F6 ~
; strip to bare address' B6 g7 F$ \, K
full_path := RegExReplace(full_path, “地址: “, “”)
: e; M7 }0 e; g$ S& q ; Just in case – remove all carriage returns (`r)3 ~6 O$ m* O4 Q
StringReplace, full_path, full_path, `r, , all
3 _6 Z! u% C' S, h! o1 h IfInString full_path, \
3 w$ j4 X# g4 _' F5 ~6 E {
! j7 z0 s6 I9 E& | Run, cmd /K cd /D “%full_path%”
+ |9 p1 ]$ J! S' F$ L. |- M3 G }! o, e, _6 _! f$ ^7 I, _6 {; {
else
& X# T6 k% O0 v* L: ^9 W. w {
0 o [' S. Y9 F Run, cmd /K cd /D “C:\ ”! W8 I" I! S! t& }3 t
}
+ d* N5 r" [1 e% e4 k' B }% C! ]/ ?8 C0 ]- U
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% {! ?( y- w; W
这段小代码肯能有两个你需要修改的地方6 U1 D9 n6 I$ [4 T
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
- H( q0 A5 s- m; x 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 W. x5 u# Y& D
|