此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' z6 s' d: W* {% K# H 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。) p5 ^/ F% u+ s5 H
方式一:% U7 \4 q6 A* a5 X( f, Z% W
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
) g+ f [1 | `7 m2 d 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 Y: Z8 M( e$ v. E
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
& P9 v6 w+ S) h. r- y 方式二:
w+ c! O" z9 |/ n( x/ P i# y" T 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ q+ b" N8 [; v ]4 z0 X9 c/ J! W SetTitleMatchMode RegEx
. B' o. K1 M7 c! `3 C# T% ` return
+ G7 \& D' g& U; V3 U. { ; Stuff to do when Windows Explorer is open
8 _: K9 Z$ O* S3 Q9 }! h" ^! e3 _ ;! h+ T1 X; j4 f j( [ G
#IfWinActive ahk_class ExploreWClass|CabinetWClass
8 r4 ?7 h. W3 x# d3 d ; open ‘cmd’ in the current directory( ]/ C2 ?0 ?6 I# K l6 B# C+ u: o
;7 @9 D% n- Z$ s
#c::
9 S' Q( D8 A" C! e% I0 D: O- V OpenCmdInCurrent()0 ?* j; O V2 c# L* Z& N
return
) g2 A6 W( ~8 [/ M$ l #IfWinActive+ i# c! L* y' V, D: Z( a- z5 C9 Y/ O. I
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 S9 a2 ^& ^& K0 U
; Note: expecting to be run when the active window is Explorer.: W8 W. q$ j7 N, r( b! [# n
;5 G. r2 B- z5 Q3 z6 @
OpenCmdInCurrent()5 `) I& V0 |* {8 s4 a
{5 g. m+ ]# X7 U2 Y5 I6 J
; This is required to get the full path of the file from the address bar' o2 j4 s& h9 k& u
WinGetText, full_path, A/ J' P$ R- c) o1 |( O) B
; Split on newline (`n)
) M0 b3 w# J4 _0 d6 M g9 G StringSplit, word_array, full_path, `n5 o5 u; ~3 ^2 m* Q' d$ M
; Take the first element from the array
. [9 ~. B5 H7 e full_path = %word_array1%
3 w, U+ @, w" U6 ~: X+ Q ; strip to bare address
, A- k, a4 A1 l4 q full_path := RegExReplace(full_path, “地址: “, “”)0 Z/ r6 x1 M7 q; C
; Just in case – remove all carriage returns (`r)
3 _$ D: r% z0 ?6 g/ V/ ?1 a% d) x StringReplace, full_path, full_path, `r, , all
2 Z* h9 {* m& C) n+ D3 L8 M IfInString full_path, \9 o" U, U7 z: D; p$ y, |
{
& r* T% f7 n1 g' G Run, cmd /K cd /D “%full_path%”
5 I' ?: q. |. {% I. w4 h/ \ }1 B3 ^$ g; P! ^, b8 Z
else
. C% m2 b. V7 F {$ Q% j9 b s* `. }" a/ _7 q
Run, cmd /K cd /D “C:\ ”+ r) j4 V/ `! B, L D
}" [6 H1 y/ k% A/ k6 T N0 I+ c
}
" _" Q# |) H; h7 X& ?$ w 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* D) ?3 v/ J( r( X* C
这段小代码肯能有两个你需要修改的地方
8 x$ J9 }1 @) m! k' u 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' [% C1 e& W+ X6 w
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
& v6 _" H' v9 E9 B" V |