此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
: n/ s" m9 u2 c- C/ d% l5 ?/ E L 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。) l0 F( f- G9 x% W
方式一:' c0 f3 p$ O; }% n' p$ G
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ x: { ^8 | B, O% g
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和- X, A5 \% Z) g" r& N3 F( q
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。7 ^6 j" i4 c8 P) H
方式二:
8 N0 |7 }4 P* H9 O/ M W3 o 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. q8 T1 d2 p5 N8 M" q
SetTitleMatchMode RegEx
/ h* W2 ~1 P* M return5 T* }* d+ A" Y; W" x4 U
; Stuff to do when Windows Explorer is open
A- I% S, z# ^, s2 Q+ G4 z8 ? ;
1 r$ B0 u6 w) o9 F" W0 l$ \ F #IfWinActive ahk_class ExploreWClass|CabinetWClass
( g* U8 \9 U4 ~7 S ; open ‘cmd’ in the current directory+ b+ d1 w+ e, f: t& o9 P/ V
;4 o* y# ^' B7 S) M2 D) I) P3 U
#c::
0 b$ @! ^3 G! T I7 K5 {+ Y OpenCmdInCurrent()
5 A- F" h3 W- A! \8 T return
, R+ ^' S) E" G2 Y( B #IfWinActive, A0 b) C; o9 j: Y3 F& H9 J1 Y1 O
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.4 I. h& ~% t3 U$ N
; Note: expecting to be run when the active window is Explorer.
. ?! r0 L5 p& Y7 s* f; t ;
' Y5 R4 U9 D6 N: P7 n OpenCmdInCurrent()
5 t0 r- q/ O1 p ~ {
# _3 l+ g/ N. |7 ? f3 y9 [3 K ; This is required to get the full path of the file from the address bar
0 ~$ i0 _& f- I5 E4 v+ v WinGetText, full_path, A
& R1 f. J/ Q9 b8 W ; Split on newline (`n)
1 G- g$ J/ L, ~1 I+ c& j t StringSplit, word_array, full_path, `n
/ A ~; Z; ?6 h: R! m x, y+ O ; Take the first element from the array2 L# Q: m9 J" e6 `
full_path = %word_array1%$ d- i% b/ V$ l$ O$ f
; strip to bare address# t$ D6 c! z- V6 i& M: B
full_path := RegExReplace(full_path, “地址: “, “”)
+ ] C+ n0 p% p7 v ; Just in case – remove all carriage returns (`r)
8 X: [/ {+ c7 z$ g% e% c; e2 B StringReplace, full_path, full_path, `r, , all/ h H, i/ g, p4 B
IfInString full_path, \% [# V+ x5 g, J( \+ q; v
{
7 L! q" Z/ Y7 w! K& y9 `! b7 f* s Run, cmd /K cd /D “%full_path%”
* D& Q, W% k; d+ w }# ]4 }: |- z) j3 E( j- K$ |
else
; ~) E8 H, ~2 P5 h# \ {
) q$ C+ v5 w/ \% \9 ~ Run, cmd /K cd /D “C:\ ”9 u! A( K% ]) H8 _/ L8 Y. X
}) U9 W3 D8 V Z2 E: M
}1 F7 P1 F: Q; w: |! }
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: O. R$ z; z' u0 I1 R9 ` 这段小代码肯能有两个你需要修改的地方+ k7 g& I" p9 p3 A# t2 Z, X/ o3 }
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 S% w$ l; p( c/ `, J
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* T6 Y7 Z2 u9 |. s/ I$ j8 n |