此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 y5 L* |3 y o7 l$ M
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
2 l( u7 P' a: i! p% o6 R 方式一:
% X9 h) Q! N7 g4 U 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,7 r# x$ @. l# P% i0 @8 r1 O a3 I
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 P9 Z9 }% b9 B- p8 M } HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 X4 f0 d5 p" A2 I; D# ?5 ` 方式二:& W4 @' {9 S, O9 g5 K0 [! d& R) J
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 P$ B! i# g2 V5 v9 Y
SetTitleMatchMode RegEx' ~4 H V8 H: j) ]. f/ B* \
return
" Y7 E8 b2 B) T( o+ Z* |# P ; Stuff to do when Windows Explorer is open2 {( W' L: S( ]: j
;
& T$ e9 k2 U; ?' r B: f #IfWinActive ahk_class ExploreWClass|CabinetWClass
; y# ?; h) ^( ~( m ; open ‘cmd’ in the current directory
1 W- K9 L" L1 E. L9 d; f0 u) _ ;* @0 ]4 N" R7 ?0 [) E+ [
#c::4 f: K6 F, q4 S# r4 D8 j& u- E6 ]
OpenCmdInCurrent()
) z$ @8 P4 F' N return
8 {) \4 P2 q( h #IfWinActive" ]' H5 }9 w4 d
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.$ ]: @: a% [8 E' h
; Note: expecting to be run when the active window is Explorer.6 R4 ~" B* ?5 a( T& y
;
2 ]5 X8 n8 v% `" y OpenCmdInCurrent(): H+ C0 c) c2 |/ N
{' L1 K j9 o( O6 q h7 ?
; This is required to get the full path of the file from the address bar
: r3 x4 F$ g! U& m WinGetText, full_path, A1 C* |' d3 j: T% M/ e5 L+ @& v
; Split on newline (`n)
9 o- W, S, c3 Y4 y* L# ^ StringSplit, word_array, full_path, `n1 g% F. [& K. _% m( c b) `
; Take the first element from the array: |, ] g9 x# }
full_path = %word_array1%+ W+ |8 i: H% N$ C& o
; strip to bare address0 T! F Z! } Q t
full_path := RegExReplace(full_path, “地址: “, “”)0 G- x- j5 M5 R& h
; Just in case – remove all carriage returns (`r) H$ @; N) P! d$ _, R. _
StringReplace, full_path, full_path, `r, , all
9 m. G3 _4 A/ J% e" e _2 W% b! { IfInString full_path, \
( T7 J1 q* z0 L {
! Q4 h7 s2 X, B7 h* E0 R4 Q Run, cmd /K cd /D “%full_path%”
& T5 l# k8 U& } }
8 g2 e2 w1 C9 b9 d8 H; a9 S else
0 X4 z+ O8 t# h% } {
+ D0 t! N( {* B, B# ~7 } Run, cmd /K cd /D “C:\ ”- k% s6 _& h; g( l" ^) B
}: ~* C. g) }3 \+ j+ B6 I6 q1 {" I
}4 T! w, p4 Q6 b i, m
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- ?! f8 k7 o0 [ 这段小代码肯能有两个你需要修改的地方4 b* H4 e: n7 H& s2 m
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键, ?' V7 N& i' T5 g/ Y) b7 w2 M* W
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 ~$ n* U) Z, G$ D" k4 L0 d2 \4 c- c |