此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
) T: }: k) N! u( e; `* c2 V 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。2 q2 Y% w5 [1 Q$ x+ Y) |/ c
方式一:
6 U- s( ~* [9 C% [8 n+ ` 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,) U5 P9 t3 u% t! ^9 X
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
$ n1 A [5 u% u b. B' C HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
O+ d& s. M j; Y2 x, N/ k 方式二:
b, P0 u! K3 t. u1 R& e; V 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 `( U& F8 M: J/ Z. ^
SetTitleMatchMode RegEx0 r0 ]3 c9 B F! J/ F, `+ M: T% Y
return9 E# }+ [) a" D- q6 d8 C% y9 y1 r3 `" |
; Stuff to do when Windows Explorer is open
4 U- U5 ^' E# _: Z+ l, C/ N ;" F5 f* W, B" O2 T; N5 ^
#IfWinActive ahk_class ExploreWClass|CabinetWClass! Q" t% w7 L+ w0 h2 g' G
; open ‘cmd’ in the current directory
. Y4 a4 G9 |7 m: O ;! ]3 _+ [- R$ I$ G1 |
#c::
; p5 Y5 a; L. j$ p9 B% @ OpenCmdInCurrent()( }' D% P3 j8 S1 [
return
h% H8 \' P9 J #IfWinActive9 Z+ i: `/ x3 E
; Opens the command shell ‘cmd’ in the directory browsed in Explorer." ?7 T! i) O1 u# y
; Note: expecting to be run when the active window is Explorer. z9 ~6 D- A: r! h, h3 `5 y3 e
;3 \# d% z& T+ y/ w! `9 D" P1 F9 I7 S
OpenCmdInCurrent()
# V5 K: Q8 x/ H {/ _$ g* q. d( O
; This is required to get the full path of the file from the address bar* ^1 \# n$ {, {, t3 ^
WinGetText, full_path, A7 g+ g4 I Q- w
; Split on newline (`n)6 `/ ]5 X+ o4 L4 j4 [% B5 I2 W' F7 }
StringSplit, word_array, full_path, `n
$ k& F4 ]: d" E9 ?' i: j8 V ; Take the first element from the array' f' {; N9 T4 m" v6 t( o" ^ _# c2 H
full_path = %word_array1%& M+ s2 p8 X* } i
; strip to bare address
r3 u& R) J% o, c( {4 Q( d! m0 P full_path := RegExReplace(full_path, “地址: “, “”)" Q' k3 v5 j: w
; Just in case – remove all carriage returns (`r)& F0 Q) c5 W) U" y" j6 ?* v
StringReplace, full_path, full_path, `r, , all
# P }" v5 ]$ d8 a IfInString full_path, \
$ W- _ H/ E' U {
! J9 e# K8 c" d5 P: M& ~ Run, cmd /K cd /D “%full_path%”
( A+ M% R2 v6 t' E# o0 Q2 g$ t }
) A& `5 z* _* x# @. } else
5 B c) ?3 W" s. I/ Y/ F {
5 G5 ~; [8 T. V Run, cmd /K cd /D “C:\ ”
7 k" q; }# J1 H& f, b }8 n; _: m# I* Y4 m
}
. G. A7 V7 \2 O( `# c% S$ x1 @8 z5 F! x 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# {5 o/ S, L8 k D/ D6 v( k 这段小代码肯能有两个你需要修改的地方0 {* N% ~/ A/ ]9 O7 x
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ m1 I+ z j3 k6 F9 X5 L% b/ r 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, v6 n4 z8 S% Z+ s. i
|