此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ ]' v& h# j4 F
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, B8 q9 f- s( ]/ r- K( A! P 方式一:# w2 _2 f/ D. n! Z3 Q( D! \- n
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表," Q- _" {* o9 s8 Y* j
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和( ?, a' i( Z# H, J6 w3 s( G
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 L8 g! [4 i7 d* w9 x 方式二:7 w" q q% l% C4 C9 V
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" i, A4 g4 |) G/ n! ]5 V
SetTitleMatchMode RegEx4 Z2 h# f0 I0 Y% E5 E# k
return
0 U3 ?3 m" Q/ @! O ; Stuff to do when Windows Explorer is open
7 j/ {/ [/ d2 {6 N7 b. N ;7 p% h+ e/ H% w1 e* }9 _
#IfWinActive ahk_class ExploreWClass|CabinetWClass( x1 u( H' H2 j8 L
; open ‘cmd’ in the current directory8 J" P, m; H, |% }4 L! Q
;
# k" c+ I' D5 m #c::3 z2 J. p+ `2 J9 M3 Z
OpenCmdInCurrent()3 u! z: k W. G/ D6 p0 I$ m
return
: F- ^& I1 L- f #IfWinActive8 x% B; [6 N d0 F, B0 T$ D" Q
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) X7 y; M$ W8 `) m# q6 Q
; Note: expecting to be run when the active window is Explorer.
+ p. t% J( L. b% k7 ^4 B5 P3 L ;7 m* u" x! E. ~$ B; M; Y
OpenCmdInCurrent()
|( u3 H! n/ f% K {% i7 x: x% L) ?
; This is required to get the full path of the file from the address bar
8 h. ~" U3 J; R" S% a J WinGetText, full_path, A
' [8 m' O3 V I: Y5 s ; Split on newline (`n)
4 H8 @2 ?$ g0 q, O! | StringSplit, word_array, full_path, `n3 |: z/ v' i/ g- W% t
; Take the first element from the array# V9 v% d) o5 u( V# t
full_path = %word_array1%
8 O* T, K$ j/ u, K& I" |9 _0 S* n ; strip to bare address, y3 h6 c& |7 M$ G' v
full_path := RegExReplace(full_path, “地址: “, “”)
' C v+ |2 m5 ~5 j ; Just in case – remove all carriage returns (`r)# D+ @* H) L' k/ X
StringReplace, full_path, full_path, `r, , all& A$ u5 S0 D2 Q) m! M
IfInString full_path, \
3 ^; f6 ]! w- s7 K {. j: d5 L. t; }1 B$ [! o
Run, cmd /K cd /D “%full_path%”
; C) Q! i& l& s* a [ }6 H' f8 S- x }$ v$ w9 B4 G
else
* S# W: T/ g* j+ W' p7 I% Q {
9 T" a+ g- N2 i2 I1 [" f$ a Run, cmd /K cd /D “C:\ ”' s+ z( l. _# G9 O4 X: X @
}2 }, S7 J. U4 H% C2 f3 J3 Y- S
}
7 K. [0 o/ ^3 a0 g2 H8 {$ N g' D5 ~ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。$ z l7 n* e: ]* M
这段小代码肯能有两个你需要修改的地方
% l7 R( Q7 z9 W7 s5 a 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
* Y6 h3 @, {- I 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
' m- b4 A7 V5 k- f" h |