此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
! {* w0 d* u5 t7 s6 |4 |% Z 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。& I$ s' ~) b5 l5 E- @5 f/ v7 W d
方式一:4 x" C% A3 `& H
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
* Y8 P& R0 G8 u- a3 r' d 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ R7 s" v8 m' `) O+ B2 _ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ w, |* H8 t0 C- p) R/ F 方式二:
# A" \& D& M8 m* f 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
4 m* A3 X! g+ X% p/ U: H SetTitleMatchMode RegEx
9 p2 i4 Q ?" `7 R7 p1 v+ n' a3 N return
$ V7 U* [" Z3 x9 H6 O% I% V* M ; Stuff to do when Windows Explorer is open( a5 M! e! R! Y' Y+ N. \
;
: M" P$ U9 w1 b* }6 E T #IfWinActive ahk_class ExploreWClass|CabinetWClass
2 l1 n2 _0 z9 F# I$ K6 l6 f5 o) N% \ ; open ‘cmd’ in the current directory6 [3 ~) V( O# B3 b
;& j g9 E, ]% I$ g
#c::- K0 m) t/ M) i2 G0 q8 F% {$ P
OpenCmdInCurrent(), D8 J5 l% Y8 t4 B* M
return- R) q& I0 P4 d5 \! t. Q. S
#IfWinActive Q+ E0 N+ ?& K0 E# S( E9 F
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.4 V+ U' n) R- Z5 I4 u9 o9 Z* Q
; Note: expecting to be run when the active window is Explorer.
% z7 R. g/ \" c3 ]& @8 @! Q ;
0 l% m+ V5 S Q& G* v OpenCmdInCurrent()
5 L# O/ }& U. I, {& e7 C' \/ s {
* H, ^/ D; C* p) q; k ; This is required to get the full path of the file from the address bar3 P! l# F& Q7 i2 C
WinGetText, full_path, A5 w* U- t5 |( e3 L/ Z( Y& j
; Split on newline (`n)
( y7 Y0 ~1 C1 ?1 L! j StringSplit, word_array, full_path, `n
6 }, v* N( m1 v4 P/ ~% Q/ J( } ; Take the first element from the array
, v, U& R% i0 i! c; ]' I full_path = %word_array1%* n1 l4 Q- ?5 c
; strip to bare address p; F( i5 [7 u }* u, b; q5 _9 V
full_path := RegExReplace(full_path, “地址: “, “”)
' F+ m. o& v5 a4 r# w$ X, n ; Just in case – remove all carriage returns (`r)+ b/ G" Y! L" W, v1 p; p1 m5 ~# Y
StringReplace, full_path, full_path, `r, , all
& Q( i r1 E% E- c, Z8 ` IfInString full_path, \
# J$ \3 d* b: x1 g$ g4 z4 i {
* _) X/ Y2 p) U Run, cmd /K cd /D “%full_path%”* N6 k( W1 ?- j; d" c
}: }6 W5 L3 G& q& Z y: X
else
1 F% t6 V" B- q& Y: @/ z5 {/ P {
% @0 z* b. l, y: W. a- @# p! | Run, cmd /K cd /D “C:\ ”* n0 U( j& e5 c _3 g! P
}! |" i& A# f" I- o
}
7 k7 w; a; _& @( R- \. h* \ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。. |1 Y2 Z, [# @7 A
这段小代码肯能有两个你需要修改的地方
' ]& p( Z9 _3 i, p* u+ n& { 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
; K. h3 x2 N' M0 v2 P3 ? 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “/ _2 f' ^( e0 T' ?
|