此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 F/ a% X w$ D/ S. F
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。- E; t# j* ?: {( ]
方式一:
) r8 }$ J& b( a3 l: k1 O 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ ^3 p3 ~6 `3 y2 ]/ n B/ x
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和& H8 T; j1 R4 Q
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ s: ?2 M# n5 `$ K. J# ^& s
方式二:
# E* U) c k) W3 T1 G2 W 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 q: Z( D3 s4 f# f& _ n SetTitleMatchMode RegEx1 b+ y$ _* B7 Z9 @: ~/ A
return. W% p# s! t4 k; Q" x# i
; Stuff to do when Windows Explorer is open5 q7 P' E4 J0 e' ?6 Y
;
3 P* U3 K( M: c8 S( O# }* B #IfWinActive ahk_class ExploreWClass|CabinetWClass1 r& ^4 B- U7 }7 l; P6 c9 }
; open ‘cmd’ in the current directory
7 I. n& o' k, f, C8 a% M ;* k( I) \4 Q b7 u" `
#c::6 L9 l/ Y; k! k, I% x
OpenCmdInCurrent()
/ J6 z0 r' P# g) ]8 Y- t. x return6 k% M5 c5 v8 |% L# m! b9 U: _
#IfWinActive
) k, j5 G" V/ C z) f, D) k ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
" t6 p* |9 @$ G( l Y1 L2 f ; Note: expecting to be run when the active window is Explorer.
8 r: g2 \& [5 F% H( R ;& c( l2 T9 J# j3 s5 ^% w' ]
OpenCmdInCurrent()
" H5 I+ H$ H% m- K& ^4 o5 R {
) A& }' e9 I4 k+ c+ b ; This is required to get the full path of the file from the address bar
: d- M/ K, g' A9 A/ r WinGetText, full_path, A) c5 h1 z t1 y+ K. {% A6 I
; Split on newline (`n)3 Q | Y+ k; ^
StringSplit, word_array, full_path, `n
4 @" w# v( K {' S! F: W$ r, m4 V ; Take the first element from the array5 i5 M* T3 s( t1 @7 E
full_path = %word_array1%, O+ w& p; h; Z k
; strip to bare address
" p% \* j# [: L6 I full_path := RegExReplace(full_path, “地址: “, “”)& U& `7 h3 s9 h3 z8 W3 \7 k; {6 X. s. `' p
; Just in case – remove all carriage returns (`r)
: w; X4 u! _+ R1 Q) u StringReplace, full_path, full_path, `r, , all
; m) l! m2 ^. i# g( m i( h1 p6 t$ I IfInString full_path, \
1 [( h( {; g# W9 @! ]7 I {! A% @+ M0 h- u; O0 }
Run, cmd /K cd /D “%full_path%”+ T& F) \& \$ H4 F0 @( a
}" A2 z/ {: D# J2 B0 G& { ^9 \
else7 M" ?. U) I' p/ R$ \
{! s, J. D" v$ q
Run, cmd /K cd /D “C:\ ”
. V/ U3 C6 e/ v% L }+ d$ G* f. t& }1 f+ {8 J, ?
}
* X9 z: f$ d6 ?: V' ?* B$ Z 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 s$ e& t) q9 f& x4 ]( ` w
这段小代码肯能有两个你需要修改的地方9 ^7 {$ @+ M* L4 K# c
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ f4 m/ O0 J1 b( R 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
, B+ k8 r) F# C* S7 W( ` |