此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
, E3 F. b, n# m. T' Z 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: l0 P3 N. ` z* ]& ~
方式一:4 `' q0 W5 e2 x
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,& r- E' z( O: N( F. m$ t
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和$ b7 V; d+ o- n; o4 U/ M* {2 W
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 f; u1 P5 i5 B- V& {# f6 h
方式二:
' ]9 g- q4 s7 |, S' ` 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:0 k+ [: I4 K# ^
SetTitleMatchMode RegEx7 x9 s( |7 Z( {' X
return+ b% ?6 M6 }% h* |
; Stuff to do when Windows Explorer is open
/ B4 r2 N" J7 G8 ]5 b& q3 @ ;: ^7 ^" d# _( U
#IfWinActive ahk_class ExploreWClass|CabinetWClass$ p4 [* w( l" k: j* r" F
; open ‘cmd’ in the current directory \: k2 @& u+ T4 E1 j' ?
;
' V: e6 j! ?1 x3 n& m3 b# _* z. k #c::
' W0 ?8 c+ ^8 {2 c$ t OpenCmdInCurrent()) |4 n* m2 t% w+ m) _
return
* Q4 Z* J, U4 {) y) P/ c( E5 t+ V #IfWinActive8 \" W) Y0 ?0 e7 x5 G( r. }
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
8 D$ g6 \& c' D5 z5 H ; Note: expecting to be run when the active window is Explorer.
3 O% Q& ]% k$ D# m# T, |- I( a ;
( ~/ r4 e8 s+ e$ u; I9 C/ H OpenCmdInCurrent()8 q3 l; N8 o5 E( v- p% N
{3 F4 V, C% E2 S0 ]
; This is required to get the full path of the file from the address bar4 W) \: g, W3 v% j/ F- r
WinGetText, full_path, A) ^6 V* T4 N8 g! w# }+ | _3 F
; Split on newline (`n)+ b0 o. `- T5 K" O/ ]& o
StringSplit, word_array, full_path, `n. ?% I8 C/ m1 Y `3 w! ^; b; y. `1 ^
; Take the first element from the array
2 n6 T9 c4 o2 V1 v0 ` full_path = %word_array1%
$ ?6 d& `) k5 V k$ t ; strip to bare address+ P% P( r) A ~* p5 J
full_path := RegExReplace(full_path, “地址: “, “”)+ ]4 ^7 }: |; M
; Just in case – remove all carriage returns (`r)
! h9 V0 d/ h1 O7 d* y5 R6 N9 m StringReplace, full_path, full_path, `r, , all
* \, }; v' j- n. _. M/ l w" s IfInString full_path, \( `' b3 a/ ]: K/ T* ?" d+ x
{3 P: W2 w$ K. O: ~
Run, cmd /K cd /D “%full_path%”. X# h6 z/ _: I4 \
}
3 Q1 c' d/ J% R( s) b: J2 S N else# d, ?3 S4 [& A+ _# H8 Y# e/ F1 M
{4 i1 s3 d: ~. ?2 g( j
Run, cmd /K cd /D “C:\ ”, c0 y! o2 Z! Z" d+ x6 z) W
}+ X2 X e* w5 @. Q
}2 u- c3 d$ w* S( B
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- S/ A3 n$ J/ C/ [) M
这段小代码肯能有两个你需要修改的地方8 p' J# f' }$ _3 v# i0 U+ A+ p
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键- n% @" X' E4 J
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" x P$ W" ^9 K8 x: j |