此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' |" k) N8 q- s! d0 _2 f 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。# u/ T$ ^5 l1 G5 o" p9 ^
方式一: t$ U. I* d8 s* H) _
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
W0 K( u _7 Q% O* z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 u! b; ]5 c/ I9 U9 h HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
# _+ L; U4 A+ ?1 i& `8 i 方式二:4 b/ t( M. |2 ~% l) E) K4 I) R
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:) Z' \+ S0 b, Q( _
SetTitleMatchMode RegEx
1 w" F: E: z$ r. k- i) E8 ~ return% B7 o! ?; d4 f% | c8 {% L
; Stuff to do when Windows Explorer is open5 E- E. X! c3 I# H2 h
;
# w. ~6 o1 S- T f/ w2 k: j #IfWinActive ahk_class ExploreWClass|CabinetWClass
2 L! D! l2 k, y/ Q9 M ; open ‘cmd’ in the current directory- s7 U# T. z* E" O: g @1 b2 p' m
;6 f6 L ^% [2 }7 ~8 ^! k
#c::
; N; d0 D+ c2 D; s: D$ I9 b& h. K OpenCmdInCurrent()1 V3 N& V; V! N, }
return
, U# G& C. G, w& v# a* P n6 K #IfWinActive9 ] W0 D$ G# _# [( D1 C
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
# Q' d" p2 ^- H x$ z ; Note: expecting to be run when the active window is Explorer.$ u! ~; Q# E; F
;
( b4 z4 q& g$ k( T OpenCmdInCurrent()
5 O# t: M( ?6 k5 J3 J- F; ` {
, M1 e9 l4 ^* k, j ; This is required to get the full path of the file from the address bar
0 a3 A$ p* _+ S+ t8 e WinGetText, full_path, A' Q! y1 q. t* x- K% z1 ?7 l
; Split on newline (`n)
7 Y A4 D7 g; w' p; {2 |) O$ m StringSplit, word_array, full_path, `n Y; Q9 S9 E" p
; Take the first element from the array
2 q2 r! l0 b2 ~7 O; _! X5 k full_path = %word_array1%
3 A* G0 D% G# t3 {6 \3 w ; strip to bare address2 g+ Q4 d: \1 ^/ v0 F/ p. |& P
full_path := RegExReplace(full_path, “地址: “, “”)# C; c3 d) A# i
; Just in case – remove all carriage returns (`r)
( D$ ]$ R; f7 _' ^: a3 i4 g$ G StringReplace, full_path, full_path, `r, , all. b& u$ F. h$ I6 t6 H9 h
IfInString full_path, \
$ L" ?" }& t! f& W( V h {
/ {( J" G7 f$ L, h" m8 d6 \( `! ? Run, cmd /K cd /D “%full_path%”- u% _/ b6 D5 O9 s Q, _
}
2 k3 J5 k& F8 X* m6 T9 N else
/ I n! C: j" V8 Y2 x2 P! K {9 H1 U1 b# D/ {* L
Run, cmd /K cd /D “C:\ ”5 Y2 ?6 F! G: A, o4 w
}
' Y6 A$ T. M( ^7 L" R1 p }
5 A4 x& x J3 u 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( q- n4 L$ ^& y9 b' |8 f4 I 这段小代码肯能有两个你需要修改的地方$ w/ q" \/ E) }& M7 l( {+ y
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 }% Y6 |; ^5 @# A/ r
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 R, x; s, r% k; \% T1 P
|