此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ v& o9 p- _5 i! \
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。- z! ~6 h8 j5 U8 \$ J5 y
方式一:* j" e! J9 L4 F8 q, l7 c8 ]
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
. j% f; O" V/ l+ h j m7 t 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和 L7 z) H. d1 Q1 G4 R0 G
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) z( L. } Z, {1 _" P _# a7 U
方式二:
6 m/ J% n' e2 R 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:& X3 x' q9 B% f2 H( r5 \5 A+ H
SetTitleMatchMode RegEx1 F9 d6 t' `' t
return; _2 J/ {" K/ h2 L% K
; Stuff to do when Windows Explorer is open9 n2 N& S M: g8 }" A
;
" y. g5 r, I* a( H9 J, R2 i/ U #IfWinActive ahk_class ExploreWClass|CabinetWClass
1 s" d; w1 r- I6 \! Q* U% O7 d ; open ‘cmd’ in the current directory" q; {" v, k* y3 l9 O$ I9 q# N
;
* q" R6 J% l4 z% e0 r #c::
4 i ?9 x: x' b: {1 i n; ]$ K OpenCmdInCurrent()
9 h6 t) i' L* o8 {) p8 c1 c return
+ s5 `! I% B- w8 Y #IfWinActive+ U+ M) I; g* Z# X& t' q6 @
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 t# ^/ B! A8 v8 Q1 H ; Note: expecting to be run when the active window is Explorer.
. r% c. R, @/ ]/ I ;# I" `3 S1 F6 Y+ K
OpenCmdInCurrent()
1 {) C' O7 f3 C2 d. w, T% h" y {
, N3 _5 |& ~) s+ B/ H4 u$ b# Q ; This is required to get the full path of the file from the address bar
! J* N" H, p8 K5 q. n WinGetText, full_path, A! H! f' W$ Q' m- Z% D/ i! I
; Split on newline (`n)
9 O3 h! Q- A9 e+ a& x; [- n' Y& O StringSplit, word_array, full_path, `n
* H+ q6 L2 g7 j; p3 Z) F2 U ; Take the first element from the array
: t2 X5 M) C, i% { full_path = %word_array1%' ?! _% m; X+ P
; strip to bare address
{4 J7 ]9 W% ` u7 W full_path := RegExReplace(full_path, “地址: “, “”)
+ L, b2 b7 J/ j9 F% S ; Just in case – remove all carriage returns (`r)
4 L9 A* D" q# p. _/ J0 ` StringReplace, full_path, full_path, `r, , all9 j! I3 g+ K* m8 h6 p+ K
IfInString full_path, \7 n( Z6 x3 ?! U$ \0 {' r! `) f
{
7 t/ S9 g8 P8 ?9 t Run, cmd /K cd /D “%full_path%”
, g( b; K% `3 E) u; f }
5 K: a( c3 F% A, x; O( e7 q7 F else
9 j: E6 ]7 [% D0 n2 x {6 }5 b$ X# D% c, d+ |& r! ~1 \6 Y
Run, cmd /K cd /D “C:\ ”$ [6 c% s/ j: J5 j
}' c8 B, q* a) C! L2 I
}
. s! Y4 \4 ?2 b' e. M+ r! N7 b& x& I 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* z5 I" E! u6 N& P
这段小代码肯能有两个你需要修改的地方
9 b% C; g o9 V+ O @# ^ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键* u ]9 t, }5 M" ?0 _
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 r6 s% u& [2 x3 t: V/ s1 M! I
|