此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 x% u7 v7 h( U2 L) s 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。( F8 h; n; `6 ]7 D
方式一:* V* ]: ?0 x: ]$ y
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, `$ }& X& {% U, q
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 _3 q7 @- H) W H1 G$ N, r
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。 Z7 E1 [* m! V7 `) K( D" T
方式二:
. R7 S: {2 ~: e$ c' T 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:- J3 ]( z, n0 k/ l8 J3 v
SetTitleMatchMode RegEx! x; e/ ?* s; s/ P3 @- ]
return9 [7 m- p# m& }% p
; Stuff to do when Windows Explorer is open
, ]3 w% n3 J/ s- U# I ;
! f7 b7 O v1 p' r F #IfWinActive ahk_class ExploreWClass|CabinetWClass7 S3 u5 x$ z3 @0 t" C
; open ‘cmd’ in the current directory$ J% l3 N, _" v, C
;
/ Y# K0 p/ [4 C0 W4 y( a$ h #c::0 W1 t3 \: q% V7 Y( _ u
OpenCmdInCurrent()
1 F9 z; H; }; w4 v, U return
6 ?' W: l M: [7 d: r. \& E. S #IfWinActive
( }& r. o! K9 ` ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.1 [* ] |# e& }# _) _# J" w- W+ L
; Note: expecting to be run when the active window is Explorer.
* Q0 n7 W- X I0 k: r* s ;/ g& v6 b' J! n) T) ~
OpenCmdInCurrent()
( Q* U- |8 {& E0 |$ l x {
; r V3 s& z0 d' } ; This is required to get the full path of the file from the address bar
% b/ i" m) Z! D WinGetText, full_path, A
0 [0 c1 y4 `0 i M1 O- W ; Split on newline (`n)
, c7 V+ S N" a# G3 K StringSplit, word_array, full_path, `n4 D8 \% e9 n( h8 T# y
; Take the first element from the array
% C$ q8 m6 G$ m full_path = %word_array1%5 O u+ I' F7 \' ~# l
; strip to bare address/ s0 {/ ^3 F1 }* V* \
full_path := RegExReplace(full_path, “地址: “, “”)
: M" J1 `9 P, G M- ?) M8 h ; Just in case – remove all carriage returns (`r); T! b9 |7 ~5 x: |6 x5 k* g4 W
StringReplace, full_path, full_path, `r, , all, J E+ \2 I# o
IfInString full_path, \
0 o% k. T( q @+ t {
9 p+ @" s2 \: p, ~0 W+ [5 P' F) W6 W Run, cmd /K cd /D “%full_path%”$ g* D6 ] ]6 }& `4 N" ~# c
}- t, v* H4 ]3 i# @# a9 N6 l6 K
else
# l! V; u) R: `( N* O, [ {. v& I+ O0 d$ i2 h* v% G# @) J8 `
Run, cmd /K cd /D “C:\ ”0 Z/ C" V+ `# B, D$ ?2 C
}
: j' l' x, S8 T5 {* `3 t }$ l2 Q: ?9 g8 I. A. z- f
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 _+ H4 `* I* l0 W0 ~& w/ M 这段小代码肯能有两个你需要修改的地方
+ L* z4 K5 X, q) I 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
/ J7 D9 ?7 D; w 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 Q4 s( [, d! ]9 P9 ? |