此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 R4 G& b: p' Z/ K
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。/ ?; {' K8 [ @" Q' s8 O% ]' c2 y) v; K
方式一:
8 _4 f( k+ w/ ~6 x% N j; D3 l 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- N5 |3 Z, d& I9 |0 q
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
3 n( l3 U9 x x6 w' t' p9 ?4 N HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ H0 T7 E! ?/ _0 k5 `" @, L
方式二:
& t: e; V* R+ Z% [9 x 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:4 \. C' P/ h# K9 y4 h
SetTitleMatchMode RegEx3 j0 v, e) ^# z
return4 D e. _! Y: I0 X
; Stuff to do when Windows Explorer is open
1 f! T3 k1 S6 z" G+ X4 s% k/ F ;6 s# _. u- {8 } o: v' f6 h4 Q
#IfWinActive ahk_class ExploreWClass|CabinetWClass
1 x" K. i& S6 `% U, M# v: Y ; open ‘cmd’ in the current directory ]7 C6 X! O6 o& e% M0 e
;% q2 `( r- h/ L% C1 l/ a
#c::
p: [, {2 N7 \$ F" e/ l$ n OpenCmdInCurrent()
2 h7 [; I; E, W! Q' U3 o return
3 K. \! f8 u3 u& r: P #IfWinActive
# k. l7 N1 s/ v( u ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.& u% J" x. E- a0 x S
; Note: expecting to be run when the active window is Explorer.
& m; o1 G' j$ q4 E ;! e% j" T- M; Q% a
OpenCmdInCurrent()
" y1 X& G- g" s% z& d/ w {
9 i! }# u5 X t o ; This is required to get the full path of the file from the address bar
( \7 ]/ e- ?; }' d# l4 c WinGetText, full_path, A
5 G Z- t2 t+ P6 v# ` q5 ]8 W ; Split on newline (`n)
0 W2 q( Q4 P! W& \ StringSplit, word_array, full_path, `n, K1 Z, z9 E3 B* i- g H
; Take the first element from the array
1 T/ W6 \9 p9 \& t' ` full_path = %word_array1%6 N( x5 J8 h4 B( U% D
; strip to bare address g ^ L1 M2 l, m, z
full_path := RegExReplace(full_path, “地址: “, “”)* ~2 F4 J) f# h/ U# b; f
; Just in case – remove all carriage returns (`r)6 G( o* z, O3 Q- x5 j+ V
StringReplace, full_path, full_path, `r, , all
' O: B, I( G/ Q IfInString full_path, \
- a0 ^% Q$ I+ f- r) h {( E) X" k! R% x& h4 w
Run, cmd /K cd /D “%full_path%”' x7 ~) h+ U$ }0 J& B
}
" w9 _# A8 o+ t. N1 R: y else5 H: @$ {4 }. T2 @. ?
{4 b7 A4 N7 M+ z* D, d3 m9 D; K: [
Run, cmd /K cd /D “C:\ ”' P& c7 p2 w( V
}
5 z' o/ d9 d1 V3 A }$ A# Z% x# K1 ?% b
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 e; `" G) c7 ?% s2 ?+ ~0 t
这段小代码肯能有两个你需要修改的地方- }; @5 u e- W& _5 p
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键/ f! f! G, f" d
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* c% V5 M5 x+ v% z |