此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 r+ L h, z1 e% A
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 d! q5 c4 w: j* T# \8 Z+ k9 S& p
方式一:: S/ i- ^6 ^* ?7 ~; Y* E
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 k$ H: B* [6 Z' |# ] 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ {3 [7 j+ {! k. Y" \
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- ^+ l, e$ `' V- y
方式二:, L t( t8 Y6 }
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
w* o. Z3 O1 f7 M/ I( P! q3 K SetTitleMatchMode RegEx8 E+ n" f: `9 O4 [- g9 G) S: Q
return, I% ~7 a9 G5 _" ], I# A
; Stuff to do when Windows Explorer is open
. c3 I( E3 j; q2 ^( L& L* X ;
% j, H1 t {3 C" Q6 B #IfWinActive ahk_class ExploreWClass|CabinetWClass" n" ~0 B. h( x1 S9 v, \
; open ‘cmd’ in the current directory7 R0 v- {8 F. G% P$ J4 M, r0 f
;
6 Y/ M$ \- |1 O* ]1 h7 E #c::
0 C6 @, `3 L( D" o8 L' N1 ? OpenCmdInCurrent()2 j4 b7 @4 b. |& y/ y9 l
return
7 Q+ j8 a% l' z #IfWinActive
6 }1 H# E8 h$ W% p$ B ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 b/ O$ M. N) q) V9 A" a% y ; Note: expecting to be run when the active window is Explorer.
5 y3 t {3 _7 j' E1 g( _4 V) J ;
& X L, B" j' Z' j v OpenCmdInCurrent(): Q6 z/ d5 W6 `- W7 [2 r! [( z
{2 t. L$ |, T' a! g& {2 _1 w
; This is required to get the full path of the file from the address bar0 K* u% r/ E8 }" w
WinGetText, full_path, A
- U" m6 O! u' o" E1 v* j; ^ ; Split on newline (`n)# z) R1 L: f$ i( B6 g2 n) a5 V
StringSplit, word_array, full_path, `n: w4 k% B5 I" m: S0 v4 t$ l% J
; Take the first element from the array* a; W# }; E/ |( W
full_path = %word_array1%
. V$ H) ?5 N3 |7 b* @) N ; strip to bare address. f2 P5 T% H3 x' d
full_path := RegExReplace(full_path, “地址: “, “”)6 E' O. Z% [% l# U2 J3 ^# G* R
; Just in case – remove all carriage returns (`r)$ E+ a* Y+ b* i) r" `4 A- o
StringReplace, full_path, full_path, `r, , all) M* L. A, r! d& h( x* s' J8 D
IfInString full_path, \, @5 r; {( O3 K- t* r" l" f
{
: w( n3 i6 r) d+ u& I% z* l2 H' } Run, cmd /K cd /D “%full_path%”
0 O" }/ ~ y }8 G }" V! b: p% ?% l9 }
else
9 V9 v- ?; k8 E3 o) I/ L: u4 x0 E {
% P- h. r. f6 K3 s F8 i0 x' i Run, cmd /K cd /D “C:\ ”
' `* O! Z- W! O% ~8 r }8 `8 k: m& m1 q0 h
}
- y9 Y6 m6 w) @2 `5 |3 T, @ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。# g- _' `/ U3 k6 m
这段小代码肯能有两个你需要修改的地方7 D# h# f1 t; ]( d0 L5 {$ Q
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
1 W4 K+ A; G1 v: A9 g& V: J, n 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ Z8 G( k9 `) o$ y: V# Y3 p |