此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& U8 V2 q" D& C: l: C ^ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. T" M3 E/ Z+ [' z
方式一:
; a# L, q/ C# q3 r: K 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,7 F2 I* X, G) M X. f4 P5 E1 p
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" D- E- L6 D: G# \ P HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) H1 h6 S& r) e7 `9 Z; F3 W9 n7 _ 方式二:6 H! i6 ^1 f6 ]9 S+ d" q4 M/ I
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 p6 r. B/ } t1 E SetTitleMatchMode RegEx ]8 N) }2 T5 z$ X( h
return8 i- T7 `5 W7 g& u' j" R$ C' W
; Stuff to do when Windows Explorer is open
F! m; k- c( X3 Q ;
' C7 d+ X" x& C! |% w- j #IfWinActive ahk_class ExploreWClass|CabinetWClass
' I) p" N+ }5 a ; open ‘cmd’ in the current directory1 F7 d: i, P, X; z
;
! u4 T2 ^% Z5 c #c::# A0 ?8 O t/ |: d4 ~! I
OpenCmdInCurrent()
5 x) J9 H9 F8 u return, P; K7 t) d( K" P
#IfWinActive
1 {! L Q" D- w+ D ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
! b! [: z! }' x2 d4 ?: e2 o$ l ; Note: expecting to be run when the active window is Explorer.3 C0 s4 d# }/ i4 ?; W7 P
;
% G B2 y4 Q( K% W( Z" j2 h/ u OpenCmdInCurrent()
$ z! ?+ H& d: J$ C: a {
* b* \, w- I- V4 }/ `5 i# V/ L ; This is required to get the full path of the file from the address bar- z5 x- D2 w4 k8 B0 q% T
WinGetText, full_path, A
) t3 k$ s, y4 _# ~& l ; Split on newline (`n)
( P: j \$ T( @7 |( @ StringSplit, word_array, full_path, `n
$ _ ], X+ K* q! m0 f' T/ a ; Take the first element from the array
: x {# M4 ~" ?: w% ^/ T: h3 B0 z full_path = %word_array1%0 ]/ T- w% t0 J; R! k( q2 i
; strip to bare address
2 w1 e, k% ]. ~3 Q6 }) `+ B& y$ V* D full_path := RegExReplace(full_path, “地址: “, “”)% o E) I0 G$ a8 X
; Just in case – remove all carriage returns (`r)
8 J) q! v: i* h: E$ l( s StringReplace, full_path, full_path, `r, , all
2 l0 A3 v" i( S7 p# N3 H' t5 I IfInString full_path, \2 p* ?4 S/ X3 y$ X9 U2 |
{
2 c. a& }8 x+ |2 J9 F" F Run, cmd /K cd /D “%full_path%”
6 V" F0 `& E( c& b9 s8 m$ I+ N }' U/ o" A" [& D1 B% \
else
9 D, [5 E. Y* W% A% q, P$ J( I. h {% U: y, `* \5 e
Run, cmd /K cd /D “C:\ ”
9 W1 D3 b, l0 i: ~ }/ ~* V4 J( j; D3 h) K
}$ [4 f" U' P& C6 g, t' D6 L* x
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
8 R7 V, O* b* }. w. o 这段小代码肯能有两个你需要修改的地方
4 z; K, \0 o9 T8 v 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
* M; |! E: }- r+ D 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ u) j, c7 A# w! H |