此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 B/ p- C! K! r b+ k. Z2 q, L
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
- g. n8 t- h/ a8 [; z 方式一:
& C9 L" H6 F" K: e 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- G+ q4 s( v2 i3 i/ y1 s7 Y3 I
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
: g& P5 I5 T0 }, I0 N HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! ^4 R0 N" a4 g/ |6 O$ K7 _ 方式二:) D( l7 r1 H$ L) _" `; r
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! I+ T) D& d! H2 @3 W
SetTitleMatchMode RegEx, Z: @1 O) \$ J
return5 H! I3 T3 Q. K$ O( ?: s
; Stuff to do when Windows Explorer is open2 f. a9 q! q$ Q2 g% P2 F; a) @
;
8 ~' X; C6 r! v+ {+ f #IfWinActive ahk_class ExploreWClass|CabinetWClass
% t v7 G) j6 j& J W ; open ‘cmd’ in the current directory$ T# D' | L( W- d% n
;
( S7 R- B8 @( n' y% d #c::
5 M% [9 w! N: j! `7 Z OpenCmdInCurrent()" K9 S8 K4 J/ \( J; q( Z r
return
# m2 }# a, i/ ^- Q #IfWinActive& I0 \* S1 Z# G" ~8 D% D* H: N' I
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
$ t" L% `& ?) f% `; q ; Note: expecting to be run when the active window is Explorer.
7 d0 N6 f' |& N. ~# c4 v ;
0 M) I% r% [! r' n- R+ ], ~ OpenCmdInCurrent()' D$ |0 a7 a% F$ K( K
{% c8 {4 A1 ]4 Y. i& v: j
; This is required to get the full path of the file from the address bar
7 A: ~2 A! ] Q- a WinGetText, full_path, A
8 h$ L: S4 j. ]* s% \5 Q6 } ; Split on newline (`n)
1 ~) C$ B; c, y7 O1 J$ p& ] StringSplit, word_array, full_path, `n
7 d' i% @7 L1 Q3 F2 F0 @. i ; Take the first element from the array
f! r9 T" i) E full_path = %word_array1%
- q* C% A1 F% A9 K9 [' S0 | ; strip to bare address
2 L8 M, F; m S$ T+ {8 o- \ full_path := RegExReplace(full_path, “地址: “, “”)
2 p: E8 [' ?' ~/ B+ \# x ; Just in case – remove all carriage returns (`r)
9 M5 s5 o; B7 W2 T2 i- o& G StringReplace, full_path, full_path, `r, , all
, K; d" n( k) O1 R; L& c; N IfInString full_path, \5 b6 h7 ?. _! r/ p, t8 Z- E6 ^1 Z
{
% C) S9 Z2 w/ u Run, cmd /K cd /D “%full_path%”8 B* Q% G4 Q+ \/ d- G
}4 F; {6 @5 m# f8 S: l1 u" A; v: q& f
else2 k O' E9 V( R4 t" F% G
{- q8 \. z$ A4 i6 }9 S1 Z6 ?: D, w
Run, cmd /K cd /D “C:\ ”% A7 L, L/ `2 R \& i- y3 i
}: R* h4 N" r+ x( \: u
}/ {; e2 p g, y( ^& F+ {9 L" L
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 c; l. {* s" Y A
这段小代码肯能有两个你需要修改的地方$ x! a- l( ^4 a! k+ R0 J0 b- ?
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
?. u5 b0 A& N& P; Z# V8 X" D% G. X 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 h$ i: @2 a F7 E& G |