此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
$ W! b" j; V- K% h% \/ a 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
& ]$ v" L9 W# a: C' r 方式一:2 _+ g+ X i. l. R' n6 r
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,) P4 o- `# n. B
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和; z' O' }! E7 [ s' }. m
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。* l) } W& c8 R# Y$ ^1 Q1 P3 N
方式二:. \. m: V# M5 | Z2 {; z `
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, n( |0 a& \" I* `) o9 I1 L5 k
SetTitleMatchMode RegEx
/ k8 Q% X" b, B; W return
- m# p- V- O) k ; Stuff to do when Windows Explorer is open
`8 G' K0 Q3 y" I. p ;
) {+ Q& p, c. B2 `6 i- U b #IfWinActive ahk_class ExploreWClass|CabinetWClass; E1 Y/ I0 e5 |* u% @! [$ }
; open ‘cmd’ in the current directory& U& F% O- u, N. w$ B3 e6 b
;- i4 Z3 Q4 n4 g8 r9 I, t
#c::
! y- X. Q ?# C OpenCmdInCurrent()
1 o( @& A, |- ~% C0 o, w% Y5 U return; G" m( Z [. j0 L+ J
#IfWinActive5 J! [- t: ~5 q
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
2 R$ k9 Y$ l1 {# U7 H( k/ A$ Q; { ; Note: expecting to be run when the active window is Explorer.3 V2 r/ U* ~$ {
;. {( z8 a8 S% g8 t
OpenCmdInCurrent()) N* j0 B, \+ i4 O
{
9 `7 f& \7 a7 f0 r$ c' e) i1 L/ ? ; This is required to get the full path of the file from the address bar
; R' R# Z5 J) h% r* _) m WinGetText, full_path, A
j" h3 y" R) s* i: `: G ; Split on newline (`n)
8 w' D% b8 f! \' U3 | StringSplit, word_array, full_path, `n
9 C" K. f+ q Y% r' H& N ; Take the first element from the array, i, P* B! ^! }( [( a( x
full_path = %word_array1%9 K/ Q8 Y" P% j N. R; q
; strip to bare address* s1 Y( [, P5 Y0 C- P* G
full_path := RegExReplace(full_path, “地址: “, “”)
6 E% z9 A, K. t# J/ ~9 t& P' H ; Just in case – remove all carriage returns (`r)
' U0 K4 Y9 s- R( ] StringReplace, full_path, full_path, `r, , all* h' U* L \* S& I2 i7 S1 Q/ h& y
IfInString full_path, \5 f6 @9 t( V* e+ u
{
* U9 B5 q, I% R4 l- y9 { Run, cmd /K cd /D “%full_path%”
& A. Y( g% A& \# c }
! t3 O% i) v0 q0 ?; F else1 G# [* m, \# |$ L- i& N& v
{
Y, y6 f9 x; Z9 K$ ] Run, cmd /K cd /D “C:\ ”! m0 ^9 G3 W: b; w! u
}& z' k4 n% p) m
}& R0 z# _4 o; i3 M8 f
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 u0 i+ g2 o5 [ 这段小代码肯能有两个你需要修改的地方
- Z0 B1 B! ~1 M" [: ^5 l; o6 ^6 V 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; d p# C6 ?; U2 N+ m# w" @" V* D
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* y. G6 `9 f; H$ k( o# l* N1 K |