此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' D5 f: [% D }. p3 g- C$ k; b
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* I b( j1 |1 N9 }1 a: c2 l5 d 方式一:; |; k3 U5 [* @! f' X
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
: |* U# i% j: ?! b 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
( ^0 `7 T# s( Q6 e. t HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。! m5 O) s" z: f
方式二:
: P3 f" |/ G( Q2 x 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
, k3 R+ E1 z5 f SetTitleMatchMode RegEx2 [# M8 G3 Y: k( M6 l
return# r, i3 Q: L0 K6 g7 R+ C( A
; Stuff to do when Windows Explorer is open
# ]- E3 X% ~* b, ?7 W7 s ;
7 u. Z' U. u8 i #IfWinActive ahk_class ExploreWClass|CabinetWClass' x0 b/ b$ ^) G) v2 p
; open ‘cmd’ in the current directory
2 v- w9 Y, @* o: d ; c+ x6 ]# M" P- g
#c::3 w' C8 }0 S) P" B
OpenCmdInCurrent()
' B8 I4 H( r) q7 Z6 D) D2 m) A! C return& l3 a# ~, _7 S L- P# ~6 g
#IfWinActive! o5 b1 ~! _0 p. o3 n! ]/ T7 p9 D
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( L5 D6 G1 M9 W7 O) c
; Note: expecting to be run when the active window is Explorer.
8 }" c, _/ M; C- T3 J ;5 u, q8 b7 {1 O
OpenCmdInCurrent()$ D8 h* q( H1 k& {4 |4 C+ g
{$ i; a2 Y# t0 D$ }* ~
; This is required to get the full path of the file from the address bar. g3 Z- S# h7 O: o" `2 t0 z
WinGetText, full_path, A
9 g/ u! W! M$ P ; Split on newline (`n)
" @; M/ J+ w; t! E6 [ StringSplit, word_array, full_path, `n
5 ^1 Z1 O6 g0 j8 R ; Take the first element from the array
8 ?" C) C: z a% [, _# j full_path = %word_array1%6 t1 s5 _/ t0 o/ n. v5 J0 n
; strip to bare address- @% ]( b: x$ X; g" f0 X
full_path := RegExReplace(full_path, “地址: “, “”)( l( u/ t6 R% y) E4 |0 z: B5 f! Q
; Just in case – remove all carriage returns (`r)
$ y! X5 _3 |) g StringReplace, full_path, full_path, `r, , all
; w/ j& J! \9 J ~0 D IfInString full_path, \
5 f: E: z* X# k; S1 ^ {
- ?- R2 R, W; g' F( @ Run, cmd /K cd /D “%full_path%”7 f$ ~/ y& q2 ^8 T5 l
}
# i, M6 Z) L$ v else8 q* k; ^. {$ C0 ~. m) w
{# w/ a- _9 j( L4 V9 L1 ?# C
Run, cmd /K cd /D “C:\ ”
1 l% R; ?- o) q6 J. d# `- `2 Y1 T }$ V0 ]& I% I" ?3 ^! D) C/ P8 L+ I1 f! g
}* y( ~$ ]: I- x
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
& N, c6 L0 W7 x" N+ d. j 这段小代码肯能有两个你需要修改的地方
+ A/ Y2 X1 f1 s: z5 N( f5 e; [ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键1 w5 C6 H0 k2 X) j' D' t
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “( @; n- |3 H* J% t6 j
|