此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ q2 E8 s5 W: _
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* O4 p, j0 H+ r& U r 方式一:. f5 D7 P5 E6 S, _7 X3 X N8 Y) Y
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 C0 T* I( K6 |! v. ] [9 O
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
9 G) m* j1 k) c0 j HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 M) H3 [: N& `& u 方式二:* A. |2 A( B6 E7 B3 R
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:+ j; a" O h. F! T( t
SetTitleMatchMode RegEx/ Z5 k. K( g$ R
return
" R; b6 d$ u' @0 ]" g ; Stuff to do when Windows Explorer is open5 F6 G: H) g& l4 N
;
& U0 n& F6 F$ D& a4 J- s #IfWinActive ahk_class ExploreWClass|CabinetWClass6 \: l3 m6 Z* @) m! P0 s- s7 |
; open ‘cmd’ in the current directory1 X; \% g9 Y) c5 W: D! `& Y! c* \+ g
;
1 Z9 ]" f; M) g& v #c::
; h! }. W* A. t0 ?/ F- _, y' x OpenCmdInCurrent()
8 n# X% L- h7 Q2 x9 z$ |6 ?0 u; Y" x return% M& A/ b/ `2 s9 S2 }' o* }
#IfWinActive
A. l( _! a' R" A, \# H ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. l0 Y. ?& [; l0 R ; Note: expecting to be run when the active window is Explorer.
6 w$ X" |- I W) y2 ]& @ ;
- `1 f3 r, w9 v# j5 m0 _5 S: S. i OpenCmdInCurrent()
+ a% \1 |3 P* D- F% @+ G {
- ^* V4 h7 E! O) S0 l ; This is required to get the full path of the file from the address bar
) D* c- E5 f; v# |& I" n- A# k WinGetText, full_path, A
9 I2 ~' u) W2 c' K9 S: q3 m ; Split on newline (`n)
- l; W: ?& t Q e6 ?% d7 p StringSplit, word_array, full_path, `n8 |" c- z8 e- x! _, J7 M
; Take the first element from the array
8 m0 N+ h$ o5 A- w' b. m full_path = %word_array1%$ Z0 }1 k ^3 t4 q8 \+ C9 X
; strip to bare address
# q, P/ U& D) W3 ?4 ?, q; p5 R full_path := RegExReplace(full_path, “地址: “, “”)
P" L) n- x. u$ e) h2 j1 c ; Just in case – remove all carriage returns (`r). D) t5 t) S* n4 B
StringReplace, full_path, full_path, `r, , all
6 Z, q% P9 Q7 o8 v m IfInString full_path, \
6 L$ P. I$ k7 P( n {. y8 o. c3 o+ X/ J. {5 E" b
Run, cmd /K cd /D “%full_path%”
$ m( w ? D+ t( m }6 q- N4 x9 X0 d- r+ f7 C& m0 v
else! N" R3 u E; r1 N
{: r3 _1 G; U/ _; b( n
Run, cmd /K cd /D “C:\ ”' K. h) Z4 M! ?* S
}
0 X O! F6 z( z" u i! S }
- N' I7 L) H. Z- ^ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
) t8 E: Y3 ~5 M, j 这段小代码肯能有两个你需要修改的地方
2 W# H" ?1 ^- u* L* _' `4 p 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
2 `& |( T4 e: u1 ?- m 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
, _' J0 F$ l' P. D7 g4 p& ? |