此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 K0 E: n8 ^3 t7 \, [' i 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* X) F! l( C" }! P9 I' X! Q, C
方式一:; ]1 w" h. s7 T. M, g! E
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,0 u& b6 i: {3 Z$ h1 H
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 G8 r D. E2 h; i; ^3 ]) l HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 U; [ s: V! i& t
方式二:
" g8 k, h, Y Z+ D' ?2 a* O 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:/ z4 X; |2 f0 U4 h
SetTitleMatchMode RegEx) ]. V! n% _- z. h1 x# W' G
return$ A* W/ y# {7 ^* g4 r; }
; Stuff to do when Windows Explorer is open& y# _& O ^+ N+ c9 n/ O. E% @
;4 N! W( [1 O6 A
#IfWinActive ahk_class ExploreWClass|CabinetWClass
8 k) `: }% s2 f ; open ‘cmd’ in the current directory5 t+ t+ }1 o: l1 L
;1 x* q2 t/ b& U
#c::8 [. _0 H& Z: a" n3 _& u
OpenCmdInCurrent()
+ K, Q3 e4 |# Y: q return) p' E. r$ J/ ?* D M& H) {4 Y( l
#IfWinActive
& e2 I8 B" Y8 b( C9 [# }" `' t ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.7 n, a) ?( f% [0 G
; Note: expecting to be run when the active window is Explorer.
( @1 F, M" ]0 p# L ;) A" f! b1 O7 r* p2 U" y
OpenCmdInCurrent()
0 L' w. s _ a* Q( J/ p6 g {
7 E6 N6 j* ]9 ?0 d ; This is required to get the full path of the file from the address bar
, U" i" I. a% g ~ WinGetText, full_path, A5 s7 u. S$ F# H8 H
; Split on newline (`n)3 I6 }: o8 ~9 i
StringSplit, word_array, full_path, `n8 P9 Z1 H" E+ O7 g* O' g
; Take the first element from the array
0 s% S( L8 I9 Q0 J8 R# M full_path = %word_array1%
, l0 z) r2 S0 s ; strip to bare address3 V8 I5 [. U; w: L H
full_path := RegExReplace(full_path, “地址: “, “”)
2 z2 |/ v6 V4 W6 g ; Just in case – remove all carriage returns (`r)$ m/ a0 T J! R1 O- U/ h
StringReplace, full_path, full_path, `r, , all
% o2 k; I) x, o% P# y% {9 M2 K IfInString full_path, \
1 M# g5 s, N1 Z {
" G5 b6 J" h* ?3 ^- u2 b; V) k4 ^2 ? Run, cmd /K cd /D “%full_path%”3 }7 y4 @5 N) E t) d" L. A
}2 x! F1 o) I+ S9 U3 d+ ?; W, Q" j
else
' z# K9 q+ s- y: k. K {
" m, k- \0 O7 y, ?4 Q9 E( R/ q8 b/ v Run, cmd /K cd /D “C:\ ”2 R1 F' U* K5 x6 D6 y& a" y
}4 Q# H2 B' p0 `9 H8 l
}* }( y0 T# ~9 V
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
! U; X- U; h- a- ?+ S+ W! H0 D 这段小代码肯能有两个你需要修改的地方5 _' ?) i# d- E9 H. o) C
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 P/ l' e. v3 B3 K( t$ x* a
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “# M7 y& |3 m& o
|