此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。" y# e3 n& \. Y3 n8 B3 [7 b
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. L6 G' W% x% W. |
方式一:
( O1 x. V S I 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
& I, N5 W( x* G4 J/ q- N 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和$ ]: y/ y6 G8 k. s* q: {
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 Z0 y3 n+ {% f' B X/ [1 p
方式二:
/ K5 _! c. X1 Y 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ e" u6 \, j f SetTitleMatchMode RegEx
9 i. {7 r9 y( I3 _+ R return
7 T9 d, N9 {, c* t% d ; Stuff to do when Windows Explorer is open$ m; L! {- ?/ x, x6 p) ~, I
;4 [5 B% ]6 e- M- d! b) e8 N& b8 l
#IfWinActive ahk_class ExploreWClass|CabinetWClass
' ~' t; q; L0 @6 E6 W, G$ ?. u ; open ‘cmd’ in the current directory \7 ]; Z. v6 U# Y3 a
;: { }5 ~/ k' W1 {/ N
#c::
( H" w! J! L2 K) H OpenCmdInCurrent()# c% N# D( x& k; L9 x+ t8 |" H
return' j/ d( |% Q7 w. {( h \
#IfWinActive
- \4 j) W: r2 ^8 V ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
! B+ ^' f3 A& f8 S: T$ I5 i4 E ; Note: expecting to be run when the active window is Explorer.0 _1 o( M, U+ q* }2 K# \9 r* O
;
# q) V) v W1 a8 t2 [ j6 u OpenCmdInCurrent()
+ K, a6 S+ }6 _6 W {
$ V o) ], C+ L7 ]' d2 J% V ; This is required to get the full path of the file from the address bar3 }+ y; T7 f. l& @
WinGetText, full_path, A
" X; h; l4 P0 \+ A% g6 Z ; Split on newline (`n)
: [" c) B; n6 }$ J5 m StringSplit, word_array, full_path, `n
3 E( x+ H7 y0 Y: z& A ; Take the first element from the array2 s) V/ s& P/ G2 W
full_path = %word_array1%- ?4 O1 m; ~! l6 \/ X& h; m
; strip to bare address
: Y$ j5 T- `$ _: S& N i0 f' [, F4 Y full_path := RegExReplace(full_path, “地址: “, “”)
4 Z% L, i: c" b( s! }3 L# P- w ; Just in case – remove all carriage returns (`r)/ t& Y1 O6 s* H5 o
StringReplace, full_path, full_path, `r, , all, Q7 \% _) p5 D" L; n- E% l# K
IfInString full_path, \. P# d; |, U( g: b' I0 D/ s
{2 j, H! N( G# n! R! j9 V# h
Run, cmd /K cd /D “%full_path%”! _3 A% z, H ?7 f2 ~9 z
}
$ G6 {% J" A: k else6 ?5 u/ x- r! H5 X
{
6 b& _4 P6 U0 F8 S* _ Run, cmd /K cd /D “C:\ ”+ c9 S0 B' ~; x, |- ^3 w
}
2 I9 |7 P1 n( [% |% T* Y }' [" T3 W0 a% |4 E
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 i7 j* R* e( w _
这段小代码肯能有两个你需要修改的地方
* ]" d4 `5 L; z2 c' R 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
: x% o* F* L) p A- L 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
+ a3 `* G& N v' ^6 e' z2 | |