此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ _, L2 o. E& I. K/ ^' |7 _
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 e* J: o9 g2 j! d" { 方式一:
. t" R8 w" D/ h8 o 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,5 Y2 H2 A5 k& d+ N1 S9 S
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
2 l9 ]1 O, O- d) _; o% i HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 s8 b8 G% n _- C9 y$ t, I
方式二:
0 m% U. w% s% e+ V+ x( J' b 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 l& u; q. W: Q+ b2 ^
SetTitleMatchMode RegEx
. s. h. X' r6 {3 z return3 J- B$ L" R y
; Stuff to do when Windows Explorer is open
+ l7 R! E; C2 y( x9 y ; m( W! Q' t' u! x$ P3 y
#IfWinActive ahk_class ExploreWClass|CabinetWClass+ h2 M: b% E. i/ n' a; D6 }8 v" l
; open ‘cmd’ in the current directory* y9 y5 E' Z* K/ d
;0 C5 I8 G" L; N5 f
#c::
1 m4 @/ W, G+ R2 u5 Q OpenCmdInCurrent()
t6 E, O% Y3 `1 s! J return" }; G9 `5 M- q& l& I# j8 R+ T
#IfWinActive
8 ]& t- W' m& @ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer., P @# N4 P7 U. n
; Note: expecting to be run when the active window is Explorer.
; c" g5 {& U3 H ;! p) }1 T/ a) ~
OpenCmdInCurrent()9 Y& d: b! R5 ^" @. M% i( O* X) T$ b
{
5 y: u1 J$ A! a U' r. g" } ; This is required to get the full path of the file from the address bar
6 t( ?! ?4 X/ C3 T4 K6 o, N5 ? WinGetText, full_path, A
6 g# }" V2 H/ i) L ; Split on newline (`n)
9 t8 {: D% X8 I D, v9 t% P7 o StringSplit, word_array, full_path, `n
6 a$ T0 c4 h9 L% M6 {8 ?* r ; Take the first element from the array
* w- {6 g* A& A& @2 C( `5 ~% I7 ` y full_path = %word_array1% U. ` Y. f% }
; strip to bare address
+ Q4 s. S3 V+ r% R full_path := RegExReplace(full_path, “地址: “, “”) s3 s/ H) A1 ]9 v
; Just in case – remove all carriage returns (`r)% r n5 r2 v/ T2 M& J- m* |$ G3 Q
StringReplace, full_path, full_path, `r, , all% \. c! T( q% K, ]; p
IfInString full_path, \8 P+ F+ t' E9 p4 {$ s
{) G0 ~7 G$ I. ~! ^' t/ w
Run, cmd /K cd /D “%full_path%”
1 x' k4 w& q; F( N }
8 v- R; x" R- R4 _$ s2 D6 F else
$ s4 L5 U6 g- D- w {! d/ @0 a- f" S3 I% I: H6 C8 I
Run, cmd /K cd /D “C:\ ”: k0 s1 d4 I7 t/ K: U0 ^* T) ~/ J, q6 p1 C \
}3 \/ I0 ]3 L. `$ B3 ]
}6 @& [) v/ Z, U. a% [, z
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: E# b* v, h5 s9 l5 ~$ K/ P; J
这段小代码肯能有两个你需要修改的地方
/ X7 V9 i: i; F% V, s 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
5 r d0 G X( o j; l4 t& O. B 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 q% k6 R/ W; L- a5 a% u |