此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 r o: C: o0 _+ Z& g
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 Z3 a2 P, B. q3 t: u# l7 W
方式一:
: N$ v/ i5 _2 t' ?1 u 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,3 z/ l8 G* @4 H9 Y" G% `9 c
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: M5 _; V( d7 o' Y1 g* l. j
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
6 j1 W) N2 n9 }- x; [6 e" z% P 方式二:/ _2 J6 {. c6 I3 L
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:; B+ }6 @ B2 U# D5 B- |1 c5 G* P
SetTitleMatchMode RegEx8 F, H7 A7 n/ ^6 D2 c
return
/ L! ]6 w7 q, M) R X ; Stuff to do when Windows Explorer is open k2 L% t+ ]/ V6 _9 M% l' [+ ^2 @
;- H5 n' i) y) E2 Z7 B
#IfWinActive ahk_class ExploreWClass|CabinetWClass
# G1 o- m1 D" E5 t) R P ; open ‘cmd’ in the current directory, [0 M* p0 Q7 q! s# ^
;7 Q! D" T, b% R/ Q: M Y$ J+ w4 _9 O
#c::
# x: [8 P0 h' X OpenCmdInCurrent()4 U, P2 f) A% I/ J4 {% j) m/ e
return
/ ?# B7 Z( T# d) z# P2 r #IfWinActive
0 b1 F0 }% y# c% f0 j' X6 X ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.- |2 w+ o( K# }* J/ U4 j3 F, q
; Note: expecting to be run when the active window is Explorer.7 }$ X8 J+ e7 H* l' e! m
;' U! b. l* i/ Y1 g g# U
OpenCmdInCurrent()& { r! a, ~( C- q( a
{$ a$ |6 R. i1 ^5 A0 ?
; This is required to get the full path of the file from the address bar: h K/ r9 r1 |9 s
WinGetText, full_path, A" l: A n- b& j, I% W, N
; Split on newline (`n)
+ Y) C, `4 T* T5 ] StringSplit, word_array, full_path, `n0 l% O1 |1 p* y5 f0 [
; Take the first element from the array4 k" @- V# `( |. m% y. M6 u
full_path = %word_array1%
( x3 l& u5 t* c8 a% ?& y3 y9 _' T ; strip to bare address
) W2 \7 T! @ J9 S* _ full_path := RegExReplace(full_path, “地址: “, “”)
4 {6 D# c4 M0 D, X+ ^) u ? ; Just in case – remove all carriage returns (`r)& x7 V3 b; n5 h; V- `. [9 S, P
StringReplace, full_path, full_path, `r, , all
/ f' N1 E- Y; {4 Q, [# } IfInString full_path, \
$ w( N( X f* {2 K% {# B; f+ E2 Y {% i. V G0 { G) T! l$ p
Run, cmd /K cd /D “%full_path%”
- ]' i. n) z5 @$ ]! N7 @ }! j+ t. R* A4 W, A" [# `
else
+ P$ E9 `( R1 r- {9 b, M$ d u: N0 J {
# w. U" Q' y7 }. u Run, cmd /K cd /D “C:\ ”$ r! m& y0 J% p8 Z1 N* M: D# G
}& e1 v0 T( e* C* K& j0 j
}+ X; {9 L0 g. }4 |3 U' d7 o) K& t
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 D8 {1 h5 t; \; `& |
这段小代码肯能有两个你需要修改的地方
, U9 M7 Y! s9 P' c% a0 M 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键" j' Q3 _0 N$ J$ e% A
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 }% G7 _- {' G# \2 L8 t% C* Y+ K |