此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
" Z, G/ g) ?9 Z" V: _& m 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 I% G' i, b) ^! Z9 o
方式一:' B5 n' p$ A+ x: ?& J2 t# R
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ R: Y3 }6 G9 n: H. `7 ]
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和- i! Z# g" G: M8 S* n! x3 A
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
. U5 v, M+ f$ A- b& D7 k 方式二:
8 T5 z, K9 U4 \, l6 z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:' D; P# J$ ]5 I, {6 z7 u7 Y) R, I- z8 ]
SetTitleMatchMode RegEx
' [; |0 ?9 A! [/ n9 T- A return
9 D) J' @. A; w$ x4 c ; Stuff to do when Windows Explorer is open `' ?' i/ r3 E: f
;7 l0 ]# O7 n3 P: R5 s% k
#IfWinActive ahk_class ExploreWClass|CabinetWClass
1 z7 n$ J+ d; X ; open ‘cmd’ in the current directory0 Z$ H4 [2 n, V0 z7 x
;
1 ?% F# m. Q% L" [8 y #c::
& [- o2 c9 N- Q3 F9 e OpenCmdInCurrent()
1 T- G, @6 m( z7 y* d( ?( p return) A! O. b! x' C$ _
#IfWinActive
# z7 K m" Y0 M- z$ A' T! z' f* g' @ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 Z1 ?2 w8 K# k) f. e) u7 C# n+ J ; Note: expecting to be run when the active window is Explorer.
$ |; [! L4 x9 b8 V# J# n$ r ;( ~% X% D/ {' \. q6 F" a
OpenCmdInCurrent()* z. g8 R) N" r$ V3 }# S
{ I/ L) h Z4 a: u$ P
; This is required to get the full path of the file from the address bar* {/ t, \, c- v( {9 W
WinGetText, full_path, A
& o; y# ~: n5 z: v# B% H1 p ; Split on newline (`n)* w6 [! ?# I: { ^! y6 _
StringSplit, word_array, full_path, `n% I7 R! J1 u6 z7 f) u
; Take the first element from the array
, k1 O7 N7 D" ], F1 P$ c4 F full_path = %word_array1%4 \ K+ {' e3 t
; strip to bare address" b6 D" G7 U. z- v J5 G2 K, e
full_path := RegExReplace(full_path, “地址: “, “”)& G2 f9 X; ?. v
; Just in case – remove all carriage returns (`r), V4 V8 H9 J3 f, y2 R
StringReplace, full_path, full_path, `r, , all
5 h* q0 z6 I4 t4 c6 N# [" r8 ` IfInString full_path, \
3 U# |; u( E6 z9 f4 {: j. m, r {
$ v& N" Y2 A3 ]/ Q6 G: A0 \% d Run, cmd /K cd /D “%full_path%”
; E; L6 m; l/ R8 Q& h+ _ }1 k2 }" {) s9 W1 N
else+ o1 U7 i; Y! U S
{$ `/ w7 M6 n5 T% j
Run, cmd /K cd /D “C:\ ”
0 e, n# e- f+ a% m/ `. o }7 A0 \, X9 r+ z# k% H& m2 D6 r1 u
}& L7 M9 U5 x! ]
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( W: @% ^8 O0 u5 t6 u1 s3 l 这段小代码肯能有两个你需要修改的地方1 [, I5 p0 L! R% t7 f" i2 f/ a, Z& ?
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键 j8 O: P5 G3 A4 }- r
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 q) q6 y: ]" w! U. R8 X8 S |