此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* B8 R7 u7 Q' z2 M$ Y) _
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
+ y0 F: G3 _5 C0 l9 }4 a8 G) V 方式一:
* v: @; F& N: g- }* [ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
' z) G! N/ M0 @' x* W, j 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# U) u' x9 H0 R8 D
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
% Q6 u- B! ~+ I5 T 方式二:
, ^/ ], i5 |2 S2 k, ~2 d 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# w. b6 m( b4 s1 ^* X SetTitleMatchMode RegEx( R# g! v) R+ s$ g$ ^0 s" j
return5 N5 c) Z, K y, F
; Stuff to do when Windows Explorer is open9 T2 z! I+ ^+ K6 m5 k; f4 H
;7 l; @% ?2 S6 U0 Z5 A# {/ t* t
#IfWinActive ahk_class ExploreWClass|CabinetWClass
5 {% J& {, ?8 |: g d ; open ‘cmd’ in the current directory
' ]- r+ q2 u3 U. ]0 q7 o! R ;: p3 J G2 }# I% }+ E9 U8 i. [
#c::
( a( B2 r) K, [* l: @ OpenCmdInCurrent(). s7 J# _4 o" Q9 V* _9 j
return: \ \% M* j4 \$ b
#IfWinActive8 _5 _6 I( y, B; ?% Q6 r( h( p
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: O3 U1 M4 n* [' ?
; Note: expecting to be run when the active window is Explorer.
8 M! A2 V1 i4 A" Q ;5 n) _% Q% ]; f7 I1 N
OpenCmdInCurrent()3 l3 |& ^$ _4 T1 N
{" Q- P! }: }' C' J* p( S% j
; This is required to get the full path of the file from the address bar
6 J) M3 c5 f7 ^. t WinGetText, full_path, A
+ x4 ~3 k6 [* K4 v7 u& b ; Split on newline (`n)
% C5 c) |5 k6 N& P8 q$ h- s" A StringSplit, word_array, full_path, `n; `7 Z+ i) ~5 B5 r; S
; Take the first element from the array
1 B0 F; N9 G9 }$ x7 n full_path = %word_array1%: X9 h2 R! z. y* ]' i) k. G0 m
; strip to bare address
, d5 c+ k7 A/ t+ i9 k full_path := RegExReplace(full_path, “地址: “, “”)
5 P4 e M2 X) T0 _. E; X' n ; Just in case – remove all carriage returns (`r)$ h( D8 J; m8 J5 u2 P; M, ]: j
StringReplace, full_path, full_path, `r, , all4 }; K7 e- P" R( z- R, {
IfInString full_path, \; N- [ R* q9 e, Y
{
% w, h, `- s0 ?7 d' \5 G8 M Run, cmd /K cd /D “%full_path%”; p; p+ e' ]4 `7 _; p/ ?
}$ h* w* M* C- l5 p
else
/ I0 d8 c% u5 V {, u7 S7 m! b& z7 b
Run, cmd /K cd /D “C:\ ”
+ r$ P8 v5 K4 v( E0 u- @ }7 q; o& k, a- d9 D" C2 y' ]2 P# |( e; ^
}" b8 r: |) A- H: h
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
8 Z" g4 U) H I+ S% ~+ { 这段小代码肯能有两个你需要修改的地方
' n& ?9 m! |( ?. D1 Y! b( \ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& F5 B" [! z3 L6 Y0 x- @ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
Y8 z/ P6 h' _' t& Z6 j4 H |