此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% K8 _ \! H5 ^/ f, E7 Q
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。1 u* h7 ^- k" J% C( A/ `
方式一:: P) o0 {" a- m
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- q7 e# M7 S5 B; j$ k! ]
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和$ \7 p- }+ l% f
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 S4 G& W/ o5 s: {) y l r! |8 e' N7 w9 ^
方式二:
" R1 e9 c- b" m& z4 v9 v 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 i7 J p- b; u
SetTitleMatchMode RegEx0 j# F8 F2 V4 i, D
return6 ?! C) T2 Q5 J, y+ |2 t1 V
; Stuff to do when Windows Explorer is open
% `# M0 v3 U$ \* V# ? ;* _- l) z3 p" p
#IfWinActive ahk_class ExploreWClass|CabinetWClass
6 ~; h, o: B) `1 R/ {% B ; open ‘cmd’ in the current directory
/ J6 z. `: R9 h ;4 m+ R5 _$ r, O4 B) r
#c::
/ _% u' }5 S* H% m J" U OpenCmdInCurrent()5 ]( t9 F: P: N1 N+ M
return
5 B4 @# G7 Z, ? _ #IfWinActive% `& O; w3 X6 d. R& h0 S2 ^
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.% A4 p/ ]0 B0 \9 W
; Note: expecting to be run when the active window is Explorer.! j- @! s2 @' m$ v! L) m- Z
;# v8 O$ z) a9 z7 e, {
OpenCmdInCurrent()) s5 Y5 t. \) ?( s- U" W/ [: O
{) l# V/ ?/ x; D! l
; This is required to get the full path of the file from the address bar/ X) \, _$ X2 \" f6 W
WinGetText, full_path, A
) t% d' K! |/ Y0 o8 z3 i2 ~( M1 Q+ E ; Split on newline (`n)
6 ^0 w7 D, w( [5 Z* k7 Q, c StringSplit, word_array, full_path, `n+ V5 h1 _ s$ d
; Take the first element from the array
7 x. |2 O5 Z" T+ k full_path = %word_array1%
' Z" y E% R6 M# c7 P ; strip to bare address1 K* H( y1 h2 \$ y7 b
full_path := RegExReplace(full_path, “地址: “, “”)
' |. A6 m4 o7 H" d; O$ @+ z ; Just in case – remove all carriage returns (`r): e8 e. p7 B. A" {2 z
StringReplace, full_path, full_path, `r, , all
+ N5 Z$ y5 `2 ?$ y IfInString full_path, \
2 u( i) t y2 o8 t { N6 D6 E( e; n& i
Run, cmd /K cd /D “%full_path%”
; m- Y! Z7 m* Q% h3 @2 P }+ a' m& \4 @% ]+ S- U' M' u3 z$ Y) E0 D: \) o
else
- U& s" ?1 r0 Q2 p {
* P: \4 ~0 f0 D9 o Run, cmd /K cd /D “C:\ ”1 g5 ?% O3 i, J* a
}
6 i) q- b( H% Y- p8 R/ v, l }$ G. S: {# _# H7 ^8 b, ]1 X
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
4 Y. h6 Q, |2 `" G6 j8 w3 ?% \0 } 这段小代码肯能有两个你需要修改的地方9 d4 f& l( L7 V& s5 _
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
! l6 S7 |& m$ V0 M 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* s7 E/ X: N T |