此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% f b" L2 G6 m Z$ z$ m
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
+ C( W* s# I. r# L' r- @8 g" g 方式一:
( q5 s$ M5 C! J+ Y! X% O 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,! x& _3 n) i& |7 s, h
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" Y' s" z% j* s% W, q
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 w1 H* z! H5 T q$ r- {/ `5 g 方式二:& \0 S% y) S; Z- T3 [" e
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
, E- K. c0 t- A7 p. y+ ~# m SetTitleMatchMode RegEx8 E) K+ n% ?+ z6 q
return- e: |" R4 D3 x p2 S2 y9 A1 U
; Stuff to do when Windows Explorer is open5 U9 v* S: e# Z& X/ I
;- |6 y# H3 A; c U- T, [, } l
#IfWinActive ahk_class ExploreWClass|CabinetWClass7 o4 x" E9 J" J6 Q- M' Y
; open ‘cmd’ in the current directory
2 _5 j7 F& e6 _) Q6 B) p8 v' Y+ N ;
7 A3 p- G" r c. L1 |( a! I #c::
- Z1 g- ~ r3 x1 g) ^ i% Y4 b2 p" F5 U' j# h OpenCmdInCurrent()
( S- g. S2 F9 A2 u0 s+ x. k j return- J" j; _. L; k$ Y% c
#IfWinActive
. |" B" v! S9 h1 x ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 T: _- [3 a. x0 ~( Z ; Note: expecting to be run when the active window is Explorer.
/ T( m! y: K1 c ;
$ ?( R E/ I- v8 v3 v1 u OpenCmdInCurrent()
% K0 E9 R; @9 t l! M Z {
( G% q7 {( r: B+ B; ^6 B- M6 g ; This is required to get the full path of the file from the address bar
$ O9 B1 W# b+ L: [- d+ x4 e WinGetText, full_path, A
( v5 A* ^- C" o/ L0 r7 k ; Split on newline (`n)
6 d, D$ B* G9 z5 ~8 K. B StringSplit, word_array, full_path, `n9 t, P) h: f: `. O$ F
; Take the first element from the array
- \$ ~- x$ [ y1 L% E full_path = %word_array1%( w7 y3 M" x' J- Q- m& c& U
; strip to bare address* l6 p, Q8 ? ?5 k: r. x
full_path := RegExReplace(full_path, “地址: “, “”)2 P: o2 y' s) U F* q) E
; Just in case – remove all carriage returns (`r)# @( | Z8 t" p N; K; z
StringReplace, full_path, full_path, `r, , all
) T+ z& j2 Z/ e' J4 w IfInString full_path, \7 t8 t3 Y/ u/ |! ?; z+ K
{5 O, C* ^! k1 ]; G1 |
Run, cmd /K cd /D “%full_path%”/ \$ O$ X* b3 `6 R: S
}
9 e3 F M8 [" K6 n8 R else1 @5 M' _# `! q% Q5 @7 k4 F
{
# E- F5 b7 f* ~! Q9 Y$ m* \# y Run, cmd /K cd /D “C:\ ”4 h% B( Y, O& R# O+ |9 f
}& Y4 ?6 W& M' Z" e6 G' \
}
7 ~" `" z; h" x- | 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 T! N1 S; p$ L. x& L 这段小代码肯能有两个你需要修改的地方
1 ~, R* T# v0 b# N 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ U) u x) i/ X- n7 D6 t' l 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 G, m- n8 [' N% }2 R
|