此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ \$ C5 f& g4 \% `2 a3 J6 n
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
- ?4 v( j9 X' q0 H4 J. b 方式一:6 I1 j1 h! f& t) h# z
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,' B; ]& F4 F, }0 Q, e; @2 l- H. L2 ^
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和. p( R8 u9 }( c+ B# O* q
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
. J1 g+ z9 n) y. R 方式二:
# [, f/ R1 h" h, y' Q3 a 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ p+ _" ?; I1 f SetTitleMatchMode RegEx
* R S& J! \4 b return1 ?. \) J8 ~; }
; Stuff to do when Windows Explorer is open! }0 Z$ C% Z) l" x( H6 k
;! {; ~/ U p, R: R& f" } |
#IfWinActive ahk_class ExploreWClass|CabinetWClass+ X f9 M8 A1 `0 T
; open ‘cmd’ in the current directory) @* C& U* E7 N
;
( R% d( c7 E; g #c::% `8 y1 X) G* N# D7 m# j$ O
OpenCmdInCurrent()
+ n& r: X( T' d return: Q. _; s0 @8 q; d/ }2 L& y: {! d' V
#IfWinActive Y+ Y4 @( m& D2 |1 l6 u( }; r5 P, k
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
# y3 d' j/ H$ J/ z+ x0 U ; Note: expecting to be run when the active window is Explorer.+ H6 ]5 M* ~& q- Y
;- |/ _, f+ {3 ?+ e: V+ d
OpenCmdInCurrent()
. w, C6 ?4 v3 c1 e, V1 ~) w$ n {
# s7 s1 e1 R! ~9 R/ d ; This is required to get the full path of the file from the address bar' e! Z" ~1 _7 U) {/ U; d
WinGetText, full_path, A
* A4 \4 l5 A: G: v8 O ; Split on newline (`n)
, n& [5 H& J& p5 H" S; K( f* A StringSplit, word_array, full_path, `n4 T. ]# y1 y. e& D8 l( I0 U
; Take the first element from the array
0 c' ~% P4 x Y4 `/ e+ B# ^( x full_path = %word_array1%* m( z, p% h5 H8 Y2 p
; strip to bare address
$ a7 ]$ _- [9 S; x+ @0 O full_path := RegExReplace(full_path, “地址: “, “”)' p4 ~$ Y g+ H& h! C
; Just in case – remove all carriage returns (`r)
& @) |7 g$ \4 B9 [2 E& r1 a StringReplace, full_path, full_path, `r, , all
" I8 R; P) ~" R" g' H IfInString full_path, \
' H% O) R+ U; O0 f {
) |# x- U' |8 N7 q Z- P: o& S Run, cmd /K cd /D “%full_path%”; Q( X1 E7 F* O+ f% w1 n( Q) n" ^" q
}$ n1 a* F4 r4 F5 M* b# H) U
else
q! H \% x4 { {( {$ t. x+ X# u2 I* A
Run, cmd /K cd /D “C:\ ”
; r1 n$ X# H( s3 N! P, j' b }( ~% F( \9 S, j" b/ [1 |8 `! Z1 R7 d
}: C* P' k! H, d, ?
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- u. A1 d3 x2 n8 E" M! b5 y' H
这段小代码肯能有两个你需要修改的地方
2 ]) y6 Z, X; |# h& { 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) H% [5 \" H4 n3 ? 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
: |8 ]5 g0 K! ]$ S5 Q$ J |