此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& g" k8 J7 M* {) _( s- y3 M 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。+ p. l2 w3 j2 c
方式一:
- l9 D' K+ p0 Q4 F9 Y7 U 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
) i9 r \! ]- _& j" `! } 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和; }$ Y& t9 t, d3 |" T' w
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ [0 I( a8 c; P( l+ [3 q1 u7 V
方式二:: L1 d3 S* b+ \% S2 T5 G
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
; H3 i$ S" X8 v4 I4 w SetTitleMatchMode RegEx3 f8 p I! Z; t
return4 i& r/ n8 t: I6 ?8 B3 g
; Stuff to do when Windows Explorer is open2 B% M3 s: u" U: Z, T P7 ^% \
;% N1 l' j: Y3 Y: K
#IfWinActive ahk_class ExploreWClass|CabinetWClass
5 W; ^' z9 E( S4 S, c, ]' j ; open ‘cmd’ in the current directory% Q) J" Z8 `3 {, b
;, L6 k- V2 o! d# \. c$ ^" G
#c::
6 @: v0 ]# h# n$ {! d: t OpenCmdInCurrent()
; T0 \- F8 r$ s/ |* W* W; x return
$ V; I9 u3 L( g1 c, z3 M' M4 _ #IfWinActive4 [: X( W4 j i; j& T: _, d% ?
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
& r. E8 A, g2 x. o( @. I( c ; Note: expecting to be run when the active window is Explorer.
6 N9 i- ?; S% i+ ?/ [3 q9 J ;: J! P4 X+ O4 f% c: D2 g9 k
OpenCmdInCurrent()! A* F3 d4 [% |, S T9 v
{- e" ]" I- B- B6 ]* D0 V
; This is required to get the full path of the file from the address bar5 y1 l, I- E) G3 E. n; W" z
WinGetText, full_path, A1 r- X( \* ~2 G; ^ g s
; Split on newline (`n)
/ i: @% `$ S" m4 B# T+ F9 `3 c0 G StringSplit, word_array, full_path, `n
5 [# m- }; A" ?2 \! l) q1 @ ; Take the first element from the array
) ~, q: I: [6 H& o3 A full_path = %word_array1%
0 W9 V$ Y7 @1 Q0 h# ?& u5 | ; strip to bare address
0 n0 f* z: m4 E full_path := RegExReplace(full_path, “地址: “, “”)
" I7 d: S; [' ]4 t" e ; Just in case – remove all carriage returns (`r)
( F) x8 \ n+ E) S: w4 `# g StringReplace, full_path, full_path, `r, , all1 t. }) i' t5 q9 [- B) u8 k( D
IfInString full_path, \9 m ?8 z# G; K/ Y( p$ L
{' \* ^9 ?. f6 s9 @8 C
Run, cmd /K cd /D “%full_path%”
0 M: r4 L o9 g3 z3 s) Y }
" C3 L/ A9 O9 u( H else+ V! p/ b5 R* C1 y" m# H" K: s
{4 k+ f, n+ a' h1 L* s7 u$ [% O
Run, cmd /K cd /D “C:\ ”+ q- k e9 E& ^6 G) C+ U* x: H
}8 Y$ H" }1 G/ }& C. i5 ~0 e- u/ g
}, u0 U% R6 G2 E; \. e
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。. k% L- h( N1 I
这段小代码肯能有两个你需要修改的地方. |1 O, d, L* J" P: D% I3 x1 o
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
- t' ~- t- x2 H; N( q1 j0 i- R 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
' z, G: ?% h- n* r0 C% b/ Y6 H |