此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ z* t% d# q& d
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% [& y' ?) J! A+ d/ l2 W" K0 ^
方式一:
8 W+ u, u( I+ S 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ ~' w! P0 z4 B# Q
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
2 P5 c5 p& W$ [" w/ m' {; B8 o" B HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 Z& }+ ]: I" g' u. N& a" S
方式二:" Q! R, N U9 K) J& t
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 I) O9 P3 _# t7 [) s
SetTitleMatchMode RegEx( w7 f/ F" \' o8 j# M
return" Z/ S; H* o- g) _, X; U
; Stuff to do when Windows Explorer is open
. ], P9 f3 y6 Q# \; u ;5 I7 y3 m/ w9 K# L' P
#IfWinActive ahk_class ExploreWClass|CabinetWClass
5 ~5 O. V2 @" [# g ; open ‘cmd’ in the current directory
. I+ U7 v6 @3 O% m8 n ; |0 P! ~( l: d: p5 M1 u6 t9 _
#c::
9 I( @* @# B* f) { OpenCmdInCurrent()( j# z: H2 [1 w# V* I
return: X3 f. {; k7 [0 O0 B! v9 V8 d
#IfWinActive, I) O# C9 R. l ?2 O7 w
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 ^0 X& e$ Q/ e4 C ; Note: expecting to be run when the active window is Explorer.
+ m# x1 Y/ z- l' S- k0 m' _ ;$ T7 c2 D( E4 R( M
OpenCmdInCurrent()( ]* V4 j$ D3 l$ s; H$ }
{3 K: _! b4 g P. y. }# }
; This is required to get the full path of the file from the address bar3 T' x; |: i- H9 j. p. c
WinGetText, full_path, A
3 y7 O" J" M/ B) p" f. W7 e ; Split on newline (`n)
3 N2 Q1 r: V( _* r StringSplit, word_array, full_path, `n) d6 k1 `) ~7 ?7 U5 V
; Take the first element from the array
^- M, S; h, b$ b' O2 ? full_path = %word_array1%
" U, x- x' m9 R5 ^, n ; strip to bare address. O4 {3 z, a/ j
full_path := RegExReplace(full_path, “地址: “, “”)1 r- r Z- q0 V9 p2 |& f' c) k- w2 x
; Just in case – remove all carriage returns (`r)
% ?, D: W' ?4 U1 t3 H; d# [ StringReplace, full_path, full_path, `r, , all8 t r r" ?: m1 V5 e+ U1 z5 @
IfInString full_path, \
/ M) `$ K" u* g) T- y. D {# [! Z; ]/ X4 X, `( m$ x
Run, cmd /K cd /D “%full_path%”
0 w9 B4 H; l, j: r* j! m& ] }
* f& H8 {+ D' K" i0 W else- B1 A* G, G! p% G5 O: r
{
$ n$ f9 E' O! B$ E/ U Run, cmd /K cd /D “C:\ ”
" y5 c7 Y) ?# a( i }* c: H9 [8 s1 @. k
}
# y ?% ?2 u9 x 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。. G M6 h' N( C, ?
这段小代码肯能有两个你需要修改的地方
, K8 R( v e: ~. l& H4 w# @5 K 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键2 A n& ]6 y8 g, F* q( x
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
+ i% d4 i! S' ? |