此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。" E4 {0 \: ~/ T& a( y
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
! a) d E% b! h( [5 p S 方式一:
9 m) e+ b* m) \, C& `" p 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,! J1 D( n, Y* A. a: E( y. D. o, q
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) @( i; q& r1 o, f7 l" B
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
: o! X% _/ y2 } 方式二:$ o( J5 X0 s' G0 L! p
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
. o1 E/ d+ {+ }& N% K SetTitleMatchMode RegEx
4 S( l) M4 R4 K$ Y$ y/ o$ J return. G. v! z' D6 J' H# I; q( f
; Stuff to do when Windows Explorer is open
' p2 }3 O( _% \. q5 e7 _7 V ;
: G! I6 v, p p& R+ `9 J3 u: B( h& G #IfWinActive ahk_class ExploreWClass|CabinetWClass6 B8 g) X5 v+ w& O& F- p8 Y
; open ‘cmd’ in the current directory+ O! s: `* m+ g2 A/ D6 b% w- S9 T7 F
;
7 e/ [9 k2 I% P' P #c::- ^5 v5 H1 \8 g1 t! d7 g
OpenCmdInCurrent()
5 e9 b; `+ ]( c) f5 e0 M return
; y" U' C7 a! D8 [$ r #IfWinActive
- G8 v0 I C) b7 `# N8 \ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) ?% y0 F# b6 p4 p$ ]$ f3 k
; Note: expecting to be run when the active window is Explorer.
8 S6 R4 K O0 e. I6 p: i" o ;# {( B0 P$ }: i; S8 d2 f# l+ d
OpenCmdInCurrent()
y' i% q Y8 {+ g! o( ` {& T7 N% Y) w/ I4 ?% _# y9 y
; This is required to get the full path of the file from the address bar
6 G( j! X( R- ?) z; i WinGetText, full_path, A) J, z3 B; ^# _4 P- ]* T
; Split on newline (`n)
. G2 Q' W( l @ StringSplit, word_array, full_path, `n% G' l# Z* G$ a! W/ z6 B
; Take the first element from the array! G4 H3 u3 \" J" @: G. f
full_path = %word_array1%
- q* O" m# g" } ; strip to bare address# T5 S5 V$ [/ q* A/ L# K2 R+ r/ V: V
full_path := RegExReplace(full_path, “地址: “, “”)$ M9 y$ {7 F1 Q( d
; Just in case – remove all carriage returns (`r)" {7 O3 v0 z4 x$ h- e# u
StringReplace, full_path, full_path, `r, , all
" y2 T2 O9 R, a IfInString full_path, \
! j7 R" D& m* d e8 y( i7 L3 E {
( b2 W& D ~; p3 f+ o- i Run, cmd /K cd /D “%full_path%”0 L5 L9 w1 Y1 G0 v2 c* _0 J8 _
}
0 _8 |' w3 g: c$ t- { else
5 _% H7 U- K$ p; p* ?# J: F {8 t4 r! k( n9 S# m6 H# N
Run, cmd /K cd /D “C:\ ”
) [9 w3 u0 v! D4 Y9 w } n, U" a2 f' x U% a8 o
}
2 z0 a! ` M# F 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。7 s: E8 `2 L* _9 y1 z2 Z% t
这段小代码肯能有两个你需要修改的地方1 A1 ]- n4 B( ]% f: O2 }# ]
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
T+ k$ x3 }5 E- z% M% U 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “6 A( S5 G0 r7 P2 s3 @
|