此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
) G3 j: w8 u8 K8 T7 O5 Q# M 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。& h/ I8 w) r2 _, \8 K1 `& K# c! f
方式一:+ d& D! `0 t+ R5 u$ {
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
$ Q, P( c3 X u) \- r 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和0 }$ _+ c, Q6 b2 i! h1 w8 j, d
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 S g9 a2 A6 ?, `- s% }
方式二:
; T; x* z' p7 v% m2 w$ W& D 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
) Q- m+ l# K$ D/ d: e: ? SetTitleMatchMode RegEx! M& Y8 z, W0 F
return# k8 P) ?, S0 L! J4 v1 Z
; Stuff to do when Windows Explorer is open
9 E* {! U1 Q f' R- X ;: e3 C9 x& ~- v) X y/ D
#IfWinActive ahk_class ExploreWClass|CabinetWClass1 r3 |2 v; v" M# ~8 j8 C) N ]5 t' {# [
; open ‘cmd’ in the current directory2 A, k$ C% }! W8 g. i$ Q) z
;. V2 i. ^) ]. h; R" |
#c::
8 ^+ G3 m3 E$ d0 l" x! e( _, c OpenCmdInCurrent()5 q, ?' ]6 g8 j$ f- P; p9 J
return( C: d* z3 I, P: n2 M4 q$ Z2 b
#IfWinActive9 H% x: T! ^: o' Y. M
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: \9 w8 D7 B, J: s: [$ h ; Note: expecting to be run when the active window is Explorer.
5 e# H$ G9 B* b1 n- o4 h i; h ;
( S7 h* j8 q; o; N4 \ OpenCmdInCurrent()! {" d" {$ _& l& E4 b
{0 Y7 B/ i" z" X. O- b
; This is required to get the full path of the file from the address bar/ e( M N m) F9 R$ j( u1 J' `
WinGetText, full_path, A
( ^" y9 u6 y' H$ [8 k& J8 H ; Split on newline (`n)# |! A t+ f' |* [% y+ ^! P
StringSplit, word_array, full_path, `n
0 h' u- K" k; N" |! @ ; Take the first element from the array# e7 I# C7 a8 Q( A/ d {
full_path = %word_array1%
$ x+ G8 X# N' Y+ k& c/ F7 ~ ; strip to bare address
' t. a2 R0 m9 R; j. D; X3 H full_path := RegExReplace(full_path, “地址: “, “”) |9 E% C1 [: K
; Just in case – remove all carriage returns (`r)& V# q( U- t! F+ v1 Z8 ]6 s
StringReplace, full_path, full_path, `r, , all
- V% H" U* b+ m( B, o s IfInString full_path, \
" b7 x6 S" \/ X$ ^6 N/ M {
0 J8 i& ~$ |# ]6 o Run, cmd /K cd /D “%full_path%”$ Z: o5 o( j1 E P
}
- `/ ^0 y, B4 W9 e$ ]) H& v else
" i, F3 {, U' @4 Y5 l {6 r# @* `$ _5 X4 P; t9 K) ]% r
Run, cmd /K cd /D “C:\ ”& p: _8 Q; u% i
}- q/ R3 e7 Y# V) h/ g
}% b! C! u$ i* @- |! m6 n: a# k
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
& E) G' M& h/ H 这段小代码肯能有两个你需要修改的地方
, |% c9 B. m% T, y) c1 u 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 e7 r' D% s, J% b3 e; x9 C5 y) E
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, d# b7 h( l2 V
|