此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。. }6 f! F$ ]; H6 }! [
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
( o' [# K1 Z* |6 F 方式一:
1 A$ h3 A, f7 ~+ p' I" F3 a+ Y 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,2 J9 J# E$ m3 \
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 Q5 g# u2 Y0 }, h% d$ X HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 I- c5 A; I* H( r& K- q' @
方式二:
, E. C' L4 k; Y5 j0 K 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& t6 p" ~. {; C1 D7 y SetTitleMatchMode RegEx
: S5 w2 g$ w; X; y) K/ ^ return
, E3 A) m- K9 U ; Stuff to do when Windows Explorer is open" O( T9 ]# X$ O) S) t: n
;
s5 I9 |; j" n2 t7 r) G1 B P; r #IfWinActive ahk_class ExploreWClass|CabinetWClass
. o! b( p; j6 ~ ; open ‘cmd’ in the current directory3 H3 J L5 W$ h+ W
;. T% M- b1 }7 b1 a: |6 [! x- T
#c::. z9 c3 K0 o) c- _2 X
OpenCmdInCurrent()* a4 D5 M1 e Z1 [6 F% S# r
return
0 R# G1 j: `9 j. f; t2 P #IfWinActive6 Y! w" p7 z' s% G9 P
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 v- N% q5 @7 d7 K4 Q: L7 s ; Note: expecting to be run when the active window is Explorer.
8 b) n- l9 M' P" h9 { ;8 A. s/ B; G8 \. K, I+ }
OpenCmdInCurrent()! J$ x# Z" Z. f: y s
{
$ L: o: K p9 ^+ W5 W% }) ^ ; This is required to get the full path of the file from the address bar4 q. K, s# ?1 P e! U2 C/ r U
WinGetText, full_path, A5 h4 M4 [- G: ]+ t9 b# e. D; a: W9 Z
; Split on newline (`n)
) j9 M6 F% H1 a0 z StringSplit, word_array, full_path, `n
" \- D ~9 D( }) D ; Take the first element from the array
3 P- e$ G1 x5 `& T! e full_path = %word_array1%8 X& \+ H6 `. y4 B% @$ |
; strip to bare address
: m4 H! r" D% P& V* a& L. [ full_path := RegExReplace(full_path, “地址: “, “”)
1 U" c" w) c) A6 S+ L ; Just in case – remove all carriage returns (`r)
( O, i6 _/ t0 ~ StringReplace, full_path, full_path, `r, , all
# ^0 H8 A" D! M) i8 m, ` F IfInString full_path, \
' e( ^! [3 A- h! U+ j {' [: N4 D5 e5 i8 r" o" T+ J
Run, cmd /K cd /D “%full_path%”
?" m1 c7 Y0 c. @: Y8 b" Y2 v5 x }
: H4 U5 B+ D9 g else' z; L% ?* T5 H3 x# \# l& O
{
& H. u$ d) z+ j Run, cmd /K cd /D “C:\ ”
" M) }* i1 c' v: _/ i0 Q l; a }
M! r* J# i" _2 l& d2 l7 F' }. h }1 i' E; V f* T- [
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! L: i! d; S0 o6 Y% ~# `0 Z7 B
这段小代码肯能有两个你需要修改的地方$ p) Z+ U8 V5 r% y
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ f* w u C% `; z+ x! ]8 P9 H 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
% U7 q" |8 S4 v4 a |