此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
" H# G" h6 g/ C. K4 L/ y. i 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。$ H4 X2 U+ W) i/ Q* ]
方式一:
& l4 @" L* |1 Y- G9 d7 T, [6 z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,0 y& s! o2 B4 f/ d3 c
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: V6 x! [1 Y+ W/ x7 x" I$ |
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" T6 j2 b G3 Y% t; | 方式二:
7 Z, O' | f! M 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 \9 ~4 j, y' {3 R5 K7 k' c
SetTitleMatchMode RegEx
4 a: y1 W8 C8 K; r W r9 W return0 e x' R8 k0 w
; Stuff to do when Windows Explorer is open
6 p+ X/ g% t; i8 B, C3 f ;/ _ C/ w8 Y$ U9 C; }
#IfWinActive ahk_class ExploreWClass|CabinetWClass% o5 H$ l* J; r3 N0 a) n
; open ‘cmd’ in the current directory4 H8 ^) X6 [* m% q a6 Y' \
;# z' G; z. {4 x {8 _5 P6 i
#c::/ `: [$ i4 B/ O# h
OpenCmdInCurrent()
$ i$ \/ O, F% d; g return
2 @( _' N/ V+ p #IfWinActive+ g" i) s N9 g
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% W& Z9 `8 W- m; E* S7 _$ Y+ Q0 E ; Note: expecting to be run when the active window is Explorer.
, O% G1 Q+ `/ I( W' ^8 Q/ \6 _7 q" e$ A, g ;
6 e4 P) ]. a0 n& e OpenCmdInCurrent()
) _ M& |( H& d' C+ P0 I" W2 T {. A3 t- W1 w+ G% W
; This is required to get the full path of the file from the address bar
- L$ T4 c! b7 }3 [' a, t# p WinGetText, full_path, A# R8 y5 e0 {3 m* t) z$ M
; Split on newline (`n). h' l% V% J" j' K; k* u6 Z, r
StringSplit, word_array, full_path, `n2 z% [/ n9 C1 a
; Take the first element from the array
# s* s8 X/ p( c* Q2 Q" o full_path = %word_array1%
% K+ y* ]3 c- t' w7 v9 C ; strip to bare address! ~% Y; j5 t4 Z1 W
full_path := RegExReplace(full_path, “地址: “, “”)5 j; @. p7 K7 L0 ]
; Just in case – remove all carriage returns (`r)4 d7 G h( A9 ^( ?
StringReplace, full_path, full_path, `r, , all# @# g# K2 |% o K% E0 v
IfInString full_path, \
3 v. o% @" {$ ?8 _& w. m, j# g {
3 y2 m3 h- w; v( v! ^' p( u Run, cmd /K cd /D “%full_path%”9 O5 V1 P! o( U( Q
}; Y$ O1 j# y; q- T. M, N' I
else
: ] M* D3 o, n% | {; ?! A2 k9 ^4 Q9 B P
Run, cmd /K cd /D “C:\ ”* H" A: W2 [# q
}
( U; H, ]# F; V. x }
% z T7 d' C! g0 F 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 I% b1 Q; ^5 Z+ I 这段小代码肯能有两个你需要修改的地方
: x8 s- x8 B5 k0 b 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
6 z9 G: I% s4 `4 K 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 m5 s5 J% s' b! e6 P" D
|