此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。. Z5 T0 _- `+ W. M$ [$ m: }4 G$ r
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! H% c r& b5 f. P: f$ q$ J
方式一:$ N1 m! n. ]8 r v5 G
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ J, X, o/ p& o
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
: k) b- V0 o: ]5 D HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 _& N2 {: S2 {; W0 g- @' C. z 方式二:9 k. y) E/ k+ A4 u4 A4 J9 P! g
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:# L2 E Q7 u) \1 K6 N
SetTitleMatchMode RegEx c, C$ ]# _* S# b
return9 y- s% f( ]: Y j h0 `! g
; Stuff to do when Windows Explorer is open# O+ Y4 R# }( v0 s7 r* ]2 K
;! j. L* m" E$ c: o' M" c
#IfWinActive ahk_class ExploreWClass|CabinetWClass
$ l7 w( P5 `% X/ y8 s ; open ‘cmd’ in the current directory
8 M$ I3 ^: q" {6 y( ]' u0 n( J ;' C; Q* G: ]; c- `* w$ g
#c::
9 Y/ Y( u# ~4 S2 f% S: i+ K% D OpenCmdInCurrent()0 H( B; b; [& S
return
+ R5 ?, K2 s7 t# t8 H. i0 I" z #IfWinActive: t1 ?% X: Z! s/ {9 f' s ]
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' a" A6 Z. L E4 `
; Note: expecting to be run when the active window is Explorer.3 Z4 O& i1 I! P5 H5 a2 y- z
;0 }$ O' n( m4 e2 F; D7 V
OpenCmdInCurrent()
* y1 P% \# { R2 o) ~ {- j4 W1 z |7 Z* M4 ^( [: g: s
; This is required to get the full path of the file from the address bar' k3 `9 C) J9 r! p# u
WinGetText, full_path, A
" r& b2 j5 i2 ^2 Q ; Split on newline (`n)+ g: p3 z$ F$ k6 W9 N% W
StringSplit, word_array, full_path, `n+ y |$ w6 J+ t+ H* U( D7 E
; Take the first element from the array% J# S; x( | s2 n- v5 v
full_path = %word_array1%( `8 J# M; X- \9 A( e
; strip to bare address; A2 |7 ~" U& o6 r" O: e( V
full_path := RegExReplace(full_path, “地址: “, “”)
F# N. d6 q$ |# r0 s ; Just in case – remove all carriage returns (`r)
- i; J0 v. e: N StringReplace, full_path, full_path, `r, , all1 ]+ s/ z$ V6 N) r! y
IfInString full_path, \
6 x* Q W6 S# k, \5 D" ~ {
/ Y- E- C2 s8 b5 q7 d Run, cmd /K cd /D “%full_path%”
( f( t8 g9 U. `3 h% Y }
* y8 Y# V7 J* e0 @ else
3 i2 b8 @! @0 F; N! C9 v, ?4 v {% c# g$ \+ f* U
Run, cmd /K cd /D “C:\ ”3 w/ C4 B! H" C/ X k* z" g
}6 ` U* Y* ~8 E+ e
} o0 V* B% D6 _
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。4 ^* m S1 [$ I8 a3 Y- F
这段小代码肯能有两个你需要修改的地方
% t; E+ q: m& B( ^ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
7 {- d5 {7 F" r5 p7 p 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “8 m1 r% s! e) B
|