此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 P! s* Y! K, i% e) m1 i' O+ W7 L
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 `; v: P( h8 d6 ?* U+ n( H# y. v
方式一:
9 @: q" r0 ?1 q$ T" v: T/ H 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* `6 U9 ^4 T6 y
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 I" Q2 u6 p( z1 ^3 ~3 B7 x HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
@( z y, x# l9 B4 U5 C 方式二:
6 m7 E8 ^6 ?1 A 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& P& f. r* D; J SetTitleMatchMode RegEx
2 q7 w( m) d0 n E$ f, S1 o% n return3 X9 B& N" ~$ Z" b, d
; Stuff to do when Windows Explorer is open
1 @ {! u$ |% p3 }! l ;
- {$ a* \0 {3 f0 N1 Y0 H #IfWinActive ahk_class ExploreWClass|CabinetWClass( d" K- M$ z8 i' H a
; open ‘cmd’ in the current directory
& z+ b9 X5 O! b ;
4 M( G$ ]7 R6 T9 f( B7 R #c::
% q7 \: W0 K/ N) q9 { h OpenCmdInCurrent()! c# y% G2 n3 Z" c- O( _
return
) k# x0 ~- a4 X' y& x1 O* y #IfWinActive
- T! X! R2 n$ } ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
, o$ T$ j. K; _& L1 { ; Note: expecting to be run when the active window is Explorer.# R0 R+ Q, ~+ s: Q
;
& _# ^% C1 @9 I6 n7 A' A6 j2 B OpenCmdInCurrent()
# x3 Y2 ?4 Y& X* t) N2 d8 m- k5 C {
; _; t$ K, W) y9 P& Y ; This is required to get the full path of the file from the address bar
* m5 |: S3 v; H7 C+ a WinGetText, full_path, A7 N) m. l! K- B5 U8 s! Y. c4 d. p! b
; Split on newline (`n)
# G5 Y7 C* k5 Y5 g. p StringSplit, word_array, full_path, `n
% s1 Q9 |" G* J5 @+ p7 A0 I$ n( } ; Take the first element from the array; N# W1 d8 F, d! l; ]* x
full_path = %word_array1%/ S. D3 }6 t. w }% F; s: E
; strip to bare address4 V4 g! z, I# j
full_path := RegExReplace(full_path, “地址: “, “”)
7 f- o) L6 k: `3 F) g ; Just in case – remove all carriage returns (`r)
1 \' c# c0 ~/ P StringReplace, full_path, full_path, `r, , all' n+ c* O& P( Z% ^, _
IfInString full_path, \
/ N* b! v2 F4 ] G6 J L {
- G4 D9 \- |; I Run, cmd /K cd /D “%full_path%”, ?' N" z; Y, x* H |; a" @9 X
}8 l% e" q0 \9 F' t! I
else$ | z; ^( {9 [3 h& ^1 i. o
{0 j' }/ g8 V4 y4 ~' Y6 m
Run, cmd /K cd /D “C:\ ”
9 s( e0 o; B* z }6 d3 _: j/ l% w5 t! g+ f
}+ m/ \: Y0 D- S6 Y, x
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: U' i2 G: g0 y4 Q# a8 z$ C7 p 这段小代码肯能有两个你需要修改的地方
! y# ~" m Z# \0 ]* D& ]5 ]+ x 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
7 V( g; `" V- u- v* J# z- ]. Q 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
( N ~* u: M# O: n. c0 M |