此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 Q/ P, T( J- d/ i. a( z: E! k1 c 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ p) F* j* o1 B0 B 方式一:
8 \+ o0 N% w0 W* p 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 L& ^& y' t& s; F8 T" x+ `$ }9 A8 S 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: v( x: {* G c" i
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。; K I7 M0 o: ^+ S
方式二:9 z/ Q K- d% Z
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 A6 w$ c# ?' ^ SetTitleMatchMode RegEx0 Z6 b( \' Z' U( f9 M
return
; A/ E* R. F4 _0 Q I7 l1 J7 v0 `) F ; Stuff to do when Windows Explorer is open
2 n9 v) E2 E7 Z, y1 n0 [3 m ;
+ m$ M' \7 t, {1 i #IfWinActive ahk_class ExploreWClass|CabinetWClass0 |, x; A& O4 |8 \0 N
; open ‘cmd’ in the current directory
0 W# x: V9 F/ n2 x" g7 [5 C ;" W% b% _/ h1 d) s! c/ ?7 ]
#c::
* g# J0 E- L& E. D4 Z& N; i OpenCmdInCurrent()) B! y: ~& f2 G6 [2 d, c- a
return
! K' K! C/ }- { #IfWinActive& G) Z6 c, {& E6 j6 S
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.7 V9 x& W7 R) T0 J4 m8 }
; Note: expecting to be run when the active window is Explorer.+ [7 @1 f9 c$ ]. y8 p: L
;; w1 i# J! s5 p! L( ?, x+ e
OpenCmdInCurrent()
8 W% V A/ ^( O( [! U( _) [' R {5 o* y& Z$ Z6 Y6 S0 K
; This is required to get the full path of the file from the address bar/ L" n" r6 O4 \& v2 z5 I0 \
WinGetText, full_path, A j% _ G- x' Q" K8 P! S* ~- z
; Split on newline (`n)
4 D& b& V4 R' v1 i% h StringSplit, word_array, full_path, `n; _' y+ A7 T7 \, A3 {# ]5 F
; Take the first element from the array+ [: V: B6 B* |2 l
full_path = %word_array1%
. w- ]7 f$ b0 U9 ~ ; strip to bare address$ v; W, [5 P% I* w! f: E. e
full_path := RegExReplace(full_path, “地址: “, “”)
: g7 Y+ b% f, e$ b$ L ; Just in case – remove all carriage returns (`r): t6 C# W, v0 A0 M! O
StringReplace, full_path, full_path, `r, , all
$ E3 A: { |( j: M9 b IfInString full_path, \
' H( W9 a3 n: g6 c6 j# |& x& ? {
M( F/ j: H' ~4 c4 F& M Run, cmd /K cd /D “%full_path%”2 d; {. c* k/ }- x: K2 |
}9 o1 N1 n3 j7 N; I" v- D
else
9 {8 q( {: g. Y; u+ |) S M) L {8 _- D: G' }( }6 }
Run, cmd /K cd /D “C:\ ”. X g$ k# s$ [* G- G1 q
}
: r! K5 |" z0 U% {. t }
# a& d; K" w1 ^0 c$ r! f 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
5 K7 V& k3 ?! X7 Q 这段小代码肯能有两个你需要修改的地方 [: j; y9 r) U0 f
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键! Q# {+ j0 D( u J
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “# x0 U) n# z1 `; r) X# M0 v2 t7 m# s
|