此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ k6 k) j5 Y6 t5 Z3 b
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。1 }, h& J, F% }: ]8 p' o$ E! g
方式一:) C1 N, x7 X ]; B" f
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 f: x2 a$ ~+ M9 Q: y8 f 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
# m8 a- G H* x HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。& Z. B' B+ I6 o( J3 U: y
方式二:
% d* P$ f- h7 @& N3 F 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! V# B" V4 z% n6 E8 w+ u
SetTitleMatchMode RegEx
; P% ^) V+ |1 B6 Q% z5 Y* M9 `# W return
8 B& b. U. d/ |- P7 N6 J1 F& J5 ?8 P ; Stuff to do when Windows Explorer is open* \7 j0 l; ~" u n" o
;
9 o( Y8 l1 P+ N- b: {! G #IfWinActive ahk_class ExploreWClass|CabinetWClass
+ r+ j4 d, P9 ~2 d# F ; open ‘cmd’ in the current directory8 m3 k0 M& Q: H$ ^7 o; J
;
4 @! K' }* Q5 z7 A7 K+ f8 {% I #c::
" K% s8 ?8 _5 M8 z- Y- ?' v OpenCmdInCurrent()
- Z: k5 _* ]: F; z0 Q8 Y return. y$ \. @ b! N! L. ?$ r& I) w P* w6 D
#IfWinActive, ?: x( u8 _8 F2 p4 I8 B
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 E W; B3 s1 S) } ; Note: expecting to be run when the active window is Explorer.- d3 o# |* H- N! N* [1 e
;
- @( L# N) e4 b8 n6 n OpenCmdInCurrent()
7 G6 P7 }% D1 N0 s0 L7 B9 Q {
1 l# \# f# f) @ ; This is required to get the full path of the file from the address bar$ N4 U- c5 c- K. ^" u$ v3 Q
WinGetText, full_path, A
+ B, a/ \ w7 X" N1 M0 r ; Split on newline (`n)
3 u! `" W# Z: z$ { StringSplit, word_array, full_path, `n1 Q/ l7 I8 ~3 W: F9 b. @
; Take the first element from the array
4 q% `% ~( |+ g0 N4 O full_path = %word_array1%9 O1 a( i7 O" y
; strip to bare address7 @7 o- [, ^; I$ c
full_path := RegExReplace(full_path, “地址: “, “”), B3 p1 X$ V: W: |" G) K
; Just in case – remove all carriage returns (`r)
& e- {% r& G6 ? StringReplace, full_path, full_path, `r, , all
) V) H( e2 s8 p; M; P: b IfInString full_path, \% k% w/ Z( l% J
{3 G! L5 s2 E5 `* \( A
Run, cmd /K cd /D “%full_path%”
* ~4 n; S7 }% F7 s: R s) K }
4 Y7 o$ A; X( m6 K else) @2 h) |9 s7 W
{/ n+ Z1 a) y s( L9 _3 o( k3 X% F
Run, cmd /K cd /D “C:\ ”
' G2 y* d! ^" N% u8 T- w6 { }
0 D! j8 a8 m: t! ^ }2 B5 v! n% _7 s2 g0 M8 N$ f/ b
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。5 c' I" c+ M* \$ L: T9 B9 {
这段小代码肯能有两个你需要修改的地方; u) [0 e. P# h0 `4 \% C
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) M, p" Z' C( F; Q% ? 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “* z, Q# }5 c3 v6 {- a( f
|