此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
4 G: T, D N6 O* q; W; N4 G 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
7 M" M l3 g0 T$ n- @ 方式一:6 W1 Y+ Y3 E3 X9 C6 l; h
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,% T9 k' X3 W7 n* [: k F+ {
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和- h- ]3 e: {7 h& T ?6 j% j
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, G/ e! d' J% i; i0 S @
方式二:# }7 z; @( H+ t% w4 x6 e( ~6 g
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: w" Z+ K H/ B% L O
SetTitleMatchMode RegEx
; f) k2 s; A; w( A5 r5 G) B return
8 R# x6 @2 r; _* g: m- n ; Stuff to do when Windows Explorer is open
8 K. k2 v, M; T! t; B/ N* @ f0 n ;* k4 G5 f! ], A2 m
#IfWinActive ahk_class ExploreWClass|CabinetWClass; M1 s' X" _: h3 l; o
; open ‘cmd’ in the current directory
* |; S3 I2 H* _, D" i ;( S% N. y1 w) \- ]5 Y0 T _5 z/ r
#c::( B5 I0 s/ H) `* C
OpenCmdInCurrent()
4 Q' ?* d# I. f. A: H return X$ d4 X: o8 N! j" N$ R
#IfWinActive
% C9 k% `4 P0 ~9 @: ?6 P& K ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) o% g$ [+ w4 u. f* i: s
; Note: expecting to be run when the active window is Explorer.* n: A4 I& x$ D' ^ J# m; R, k- {. J2 A" ]
;$ q. L' ?7 I- ^
OpenCmdInCurrent()
) p0 y8 W. u. ?& L {
" L9 ?1 m% u4 e1 P ; This is required to get the full path of the file from the address bar
) x* R# v( y* |2 ?! p7 ]* f0 K4 g5 B WinGetText, full_path, A
( x7 v4 Q/ k+ A) R ; Split on newline (`n), e0 i9 W$ J% F' a. Q, a
StringSplit, word_array, full_path, `n
# [& C/ @& b+ Y& E; J ; Take the first element from the array
" ]6 ]( Q* n ~ full_path = %word_array1%5 m$ s5 m7 b8 l
; strip to bare address
9 a/ }. S( c0 C, G& V full_path := RegExReplace(full_path, “地址: “, “”)( y e* ^% T# E3 w$ |
; Just in case – remove all carriage returns (`r)8 l k3 n; X# J6 Y, \& O4 A! ^" l, [
StringReplace, full_path, full_path, `r, , all( Q* @" k9 {8 f0 L6 y
IfInString full_path, \4 E* Q* ^! S& S+ A. | x
{# s# M5 l8 i8 t3 v9 @
Run, cmd /K cd /D “%full_path%”1 q% s# u& A, Q$ u8 b$ u
}/ u1 c7 L' o! m b$ g' c H+ ~$ l: ^
else0 V: y% K/ u6 I% }9 }" E
{) [8 _: s4 F. V7 Z
Run, cmd /K cd /D “C:\ ”' s2 U7 G2 N, U8 y! c( k
}0 @/ ?6 E7 U: o' X) R0 c9 o" ?
}5 D* Y, q# D; x- r: }
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
) @1 @1 P) T9 {/ o6 `8 l/ ^* S 这段小代码肯能有两个你需要修改的地方
% a" Y( I0 H; F" u4 v" ]9 m 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# ~) k2 n( c& U1 v
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
' i' F0 v/ U# P4 Y+ s4 \, g |