此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。: V4 }: m: j9 p: G
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
- m" k- ?5 j4 v3 H d8 ^( q, D+ m 方式一:
( V5 y2 p: a! ~/ K 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ m' k& _( c L+ D1 H% F
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 X1 u- n6 a% V i HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) a4 R$ w& N$ \) a
方式二:' H1 E0 }4 p6 k6 e) o
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
! d* }, J- U. ~9 N& A7 f1 ` SetTitleMatchMode RegEx+ `% y E0 B! q4 d
return- h; j- J# I: [5 I# y& ?& ]
; Stuff to do when Windows Explorer is open
" l6 o# r) R+ z+ p, B. S ; r; ?4 h W& D8 o" I
#IfWinActive ahk_class ExploreWClass|CabinetWClass
" l+ w0 f9 k" Z/ b# ~8 W5 K ; open ‘cmd’ in the current directory6 a2 {; h7 D' D8 N6 P
;7 ^: g- H& @1 H) I
#c::/ k0 @; i; m8 l" ^( {4 l
OpenCmdInCurrent()
9 o6 G; R3 W: a+ c( i" U return% Y( r2 g2 R4 T; M% B l- m
#IfWinActive7 A, y7 x/ ]" }# P& H1 |# @" C; T
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) D7 @; d/ O! Z" L* N' A ; Note: expecting to be run when the active window is Explorer.
! j/ z$ Y9 N ?. B j ;
9 G+ ?) a& z& T5 g3 c6 k( Q3 r OpenCmdInCurrent()! M6 m& a; D: Q
{
$ H5 B( e7 M* ]: L3 Z7 e f5 @0 B ; This is required to get the full path of the file from the address bar2 h! t H3 Z0 m4 D) ~/ O0 s
WinGetText, full_path, A
8 J0 A3 U( p& [- E* ^ ; Split on newline (`n)$ [- r4 o! X5 i
StringSplit, word_array, full_path, `n- F( M+ Z; [+ }* h$ j X
; Take the first element from the array/ g$ F% Z# p1 S1 g
full_path = %word_array1%
7 p2 d1 T9 c# ~! c) a0 j' M2 i ; strip to bare address
/ o6 }9 v# n1 R3 ?) j V full_path := RegExReplace(full_path, “地址: “, “”)
- j2 Y2 G1 A. L ; Just in case – remove all carriage returns (`r)
% Q3 \! \2 E- o. S9 d StringReplace, full_path, full_path, `r, , all
: {) B ]5 l5 z n( o6 [+ B IfInString full_path, \
1 S; X' w2 y: d( U0 M {
2 z' T& l& R! L4 I1 O! r Q) { Run, cmd /K cd /D “%full_path%”
# n& \5 X( g2 f% E, j; E }$ Q5 K4 a( B7 E' Z. \: w
else* X/ D" T E; ^1 F/ p# J8 t# H
{6 h$ N @# @/ J4 }2 w5 |" j
Run, cmd /K cd /D “C:\ ”5 [& T# Z3 y9 C+ O) P0 }) g
}/ g5 Y _8 D+ w h" c( s* p3 Q- x! p
}: _" X' I$ F7 W, j) v: C& j6 P# q
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。9 u v, j) r/ D. A3 W
这段小代码肯能有两个你需要修改的地方
+ ]0 c, K' V: j f) z- t B 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
/ p+ @0 [; m& ^/ A# O S 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 b" ^ P" |8 j, X/ w |