此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 g; x x0 x2 G1 {) O4 Z 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 z3 l# B4 E, n! c- N
方式一:
8 E3 K2 n# U' ]4 E% |; s 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
9 d* z1 \- g0 l9 A" Z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' ~0 v2 Z3 w7 A! T4 b3 C- ?0 _# ^2 Q* c
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
# W( t ~8 M! }4 e/ A" i 方式二:
% Z, j( h2 X# |# L 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 Z' X& @$ e h5 n. o/ ^1 a
SetTitleMatchMode RegEx: F& ^4 c. M% ?6 x/ n8 e6 _
return( {' v+ F" l m, r3 |% S4 l
; Stuff to do when Windows Explorer is open, K; w8 e3 p2 m' A
;/ Y' J$ v9 P& q% E
#IfWinActive ahk_class ExploreWClass|CabinetWClass
0 C! p# j8 r# a$ k5 R @# ]9 B1 E ; open ‘cmd’ in the current directory
+ F3 c A5 U7 G3 b; \6 v" L ;
G6 ^' _6 v- c" I" H, k1 _; v; K #c::
: _3 Q/ n. g0 p& i5 s) x OpenCmdInCurrent()
/ A% [4 n* v5 n" e. z6 l& G return
$ g5 h9 ]6 Z0 [8 L #IfWinActive
# |6 ~% J9 p) w: v" v+ J2 H' p ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 K! s. t; \- P# R3 s% ~
; Note: expecting to be run when the active window is Explorer.# A$ |) C6 x' z( m/ `( ~
;/ N4 |9 d6 A& c$ Y
OpenCmdInCurrent()# S/ V. o5 m7 |# c# b9 T& R
{
+ w" Z/ A. K, [$ O0 o+ z' H2 n ; This is required to get the full path of the file from the address bar+ c- S2 f) O: _& ~! K7 S0 d/ w
WinGetText, full_path, A3 y. G2 J3 l \# G: ^
; Split on newline (`n)# E9 s9 U, d6 Q2 f* H: }: `6 ^
StringSplit, word_array, full_path, `n. f& |; j( a8 d& C
; Take the first element from the array
3 ^: Z6 ~+ [0 H; H; K2 n full_path = %word_array1%
! t+ {. t# b1 d1 Y ; strip to bare address
- Q, ?; F; P- B, ?# ~' W! m full_path := RegExReplace(full_path, “地址: “, “”)0 N( V1 f9 j' Y2 Z
; Just in case – remove all carriage returns (`r); @6 q0 t+ H! V8 w: d4 }7 Y
StringReplace, full_path, full_path, `r, , all
+ `) w3 ]( g1 S( p0 N/ P7 w. R IfInString full_path, \
+ C7 F# O- s) p6 ` {3 W9 b( d" m6 H4 a+ T
Run, cmd /K cd /D “%full_path%”! ?4 G% }* M. v3 r1 o" O; Q( k/ J
}5 G/ ]# S. J4 m" q
else5 C# m) L2 t$ Y |7 ]. i* c
{
7 B, [! W) E) K2 U% ]0 j' F# V Run, cmd /K cd /D “C:\ ”/ C# q, i T \
}
# p8 k( V0 E/ f+ n( b }2 B5 f+ m- q1 _% @* ^
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。; ], d# Z7 [1 [) x. ^' e
这段小代码肯能有两个你需要修改的地方0 w! R1 o; {2 M! S/ X k
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
* W A1 V* v U Y9 [8 |0 S 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
: ^1 v Z" p" y5 S1 \ |