此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ g' k5 C$ Y6 t
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, p C1 V- [% W3 D4 X
方式一:2 J( B' l* c* D% \/ t3 L
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 H- \$ u5 x4 Z8 k8 I, r) A 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. e' c3 [" Y& q5 P HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 S; N0 l" \1 G% Y 方式二:
- E8 a, {; W @3 h) A) Q0 j 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:* u2 ], q. s5 a/ p# R
SetTitleMatchMode RegEx+ p0 \9 `2 L, K; W c$ z
return; A2 w) w( d" q4 H
; Stuff to do when Windows Explorer is open I/ d, W2 ]" z: N1 D
;$ W$ Q! b) P, m9 H) \ G0 ]: _6 {- [! J/ U
#IfWinActive ahk_class ExploreWClass|CabinetWClass
( q$ o9 K5 o1 n" ]; N7 U, D ; open ‘cmd’ in the current directory
- i* v! l* G/ q( ^: w/ y8 R ;/ V7 F! l4 l+ U" |
#c::; R- z1 _' ]. g% k o- r. |
OpenCmdInCurrent()
! s" D- u" @. C( z% m& M4 b8 f# k- r return: Z ]. ?% P6 y% x
#IfWinActive- ?8 D( ~" ~9 z, r7 u* c
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 h0 e- `$ O9 v ; Note: expecting to be run when the active window is Explorer.
t. \& |: V- i2 g8 c+ _ ;) r4 w* u) G0 W2 j5 D# W
OpenCmdInCurrent()- W6 e: N* E$ w& D) J
{
! M- x$ f0 g: F6 c) i; ] ; This is required to get the full path of the file from the address bar
0 C8 i: N, D# y. L8 e( | WinGetText, full_path, A
4 O! N+ B6 {6 ` ; Split on newline (`n)& F; }& Z' K' u3 j! Q! e
StringSplit, word_array, full_path, `n. v( G6 ]7 c$ s5 K$ G
; Take the first element from the array6 p& W( P& [; E& d4 T+ x( }0 ~
full_path = %word_array1%8 }) S g0 e, ]: |* w9 Z# H$ X; c1 z
; strip to bare address. u0 y9 i: {# E% q5 M* j
full_path := RegExReplace(full_path, “地址: “, “”)5 p& P. _8 H! L* l3 \$ |; K* H
; Just in case – remove all carriage returns (`r)
4 t6 o# V9 ~! K9 o# w StringReplace, full_path, full_path, `r, , all
2 o0 S8 h' C7 I" W3 c- L b" I0 T IfInString full_path, \
r; N9 t: b- h% L {
6 z9 q) L5 u9 s: p7 R6 J Run, cmd /K cd /D “%full_path%”0 w2 j& L6 r' f1 }. a
}
4 Q# U$ N2 k2 F) a7 {& C else
" L9 ~) |; {& n0 d! {! h, q {# E9 m: j7 g! g' H( d
Run, cmd /K cd /D “C:\ ”
- c' k. m' J- Q% U O3 p }5 i5 r8 v1 P6 i% f
}7 A/ l' H% W7 @3 W/ W
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% ], F* S( b; C: [6 U. y4 d& U z
这段小代码肯能有两个你需要修改的地方# {& q+ K5 e# S- K I3 x- z9 x
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
; |% S9 n9 {# k. r/ [3 h$ `# T4 ? 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “' @, _; e& [. U# W
|