此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- O" ~ P7 y+ h 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 H2 k2 |5 F, X' ]5 [
方式一:6 C- l( X0 V( P: K$ F
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 d* M8 @5 p# G5 I; `
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: s, C6 r. j1 L9 o7 [$ s w
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 o! ~" B& k0 f9 Q2 O5 T+ D, A9 s- k
方式二:$ [/ \5 g" U- Y9 L. X8 S
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- t/ f' Z0 {4 p+ @3 p( h0 {1 y1 s; q1 \ SetTitleMatchMode RegEx
& _# k' t0 H c6 F' P, U" Z& N) { return
* S' ?8 B; G3 | ; Stuff to do when Windows Explorer is open
! P* G6 U. J% s- Z ;
& G* |0 t0 Q5 r$ ]1 Z #IfWinActive ahk_class ExploreWClass|CabinetWClass
) ?3 P% N3 _( B- b# a ; open ‘cmd’ in the current directory6 k% v5 f i$ h1 s- M& O
;4 a9 a3 ]3 _/ Q" {3 h+ u! t
#c:: }/ `! ~+ g0 Z) O. B# Y* g: M
OpenCmdInCurrent()/ }+ c. h% F, `( t% N
return9 D2 [, J4 K- j+ s5 d/ q; f+ V
#IfWinActive' e" Y7 {5 _7 G! U' t7 z3 n8 @
; Opens the command shell ‘cmd’ in the directory browsed in Explorer./ N5 a0 ^: w( I7 N
; Note: expecting to be run when the active window is Explorer.
) |) Z/ z; U! c ;( W' c& y& j# Y. w" [! ]) G
OpenCmdInCurrent()1 _% X4 u' b( ], i! N
{. X7 V2 |. b. q) C% X, f
; This is required to get the full path of the file from the address bar, Y1 g1 m, Z0 J/ h7 E0 R
WinGetText, full_path, A
5 b+ M& p$ r# Y- h ; Split on newline (`n)( v# d# ?: A) j. B$ Y! O& C9 J
StringSplit, word_array, full_path, `n5 ~& D0 y6 _- L J9 k0 n
; Take the first element from the array
4 L' x& s( s, J7 W4 r) r- g full_path = %word_array1%
5 \! R* A+ i: r2 G/ u5 B9 ? ; strip to bare address
G2 M* \ z# R/ q full_path := RegExReplace(full_path, “地址: “, “”)7 t ^1 ~( s0 @/ N1 ]- U: P* M: g
; Just in case – remove all carriage returns (`r)
- v1 L2 B7 ~% @4 k. {) J/ L StringReplace, full_path, full_path, `r, , all- w K7 f7 I0 w$ |+ z* a
IfInString full_path, \
5 _( ~( n8 e) c; y. W! o { {! U: A) w( x, k1 l6 e Q) P
Run, cmd /K cd /D “%full_path%”
. j2 A! Y& x, \ E5 q* c' { }4 B! b6 I1 l9 J8 z) |$ ~! x* s
else
2 p0 o; q& c! u2 h { k4 ~: P! C( [+ a, c9 _" |+ k
Run, cmd /K cd /D “C:\ ”5 C% p: ?& k+ t9 U3 A
}( j$ X2 A+ X9 k, p8 D! R
}0 J! W; Y: s1 L+ B; q" u( X
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( K5 a: N1 @ E( B7 ]- | 这段小代码肯能有两个你需要修改的地方$ E+ r: U/ V. V
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键4 g, d6 u* N1 O6 |) }
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. o8 _/ C7 x. x0 C, E' d1 ~ |