此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
1 s" y. [ ]' S4 \4 P 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 J: Y. g) j' o 方式一:; s3 Y( A6 B# ]" [2 H9 y5 ^, n" [
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,' F* |7 W- Z+ M1 r3 L* D$ t/ v
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
0 Z( C6 B: ^7 w HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
; p) E& c; q Z+ H6 l# _$ A 方式二:5 g# c, i9 b1 G
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ C% E, i# G" r# R SetTitleMatchMode RegEx
0 @% y- {' C0 a7 J& ^/ P% y* x! ~/ g return7 y% C5 _" B1 N+ a. O4 C' d
; Stuff to do when Windows Explorer is open9 o/ D( A/ J; l2 w* W# Y9 j( y0 ?
;: f2 s7 u! I; v: k( b
#IfWinActive ahk_class ExploreWClass|CabinetWClass. c. h* [+ d, K
; open ‘cmd’ in the current directory
. }. ?4 n* `0 V7 G& y: x. k# Z ;
9 C% G& x) M* b. B5 r0 q8 A/ S: h5 Y, w( d #c::9 } X" x. \0 y; U2 e8 J% K
OpenCmdInCurrent()
' S7 c( N. x* d2 C3 b2 ` return
# I1 r, n7 v2 _. C! _ #IfWinActive
2 J' U$ ^. {' M ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. |: Q; _0 z; X ; Note: expecting to be run when the active window is Explorer.
" }( _+ I' n; d, J. e ;+ @, _" t) W& g6 F' F( f
OpenCmdInCurrent()
' m% G: ~. s, d* `8 k7 X {
6 Y8 |/ G5 D3 A D, ~ ; This is required to get the full path of the file from the address bar/ y, P J$ U# i, [
WinGetText, full_path, A* M8 Y- _' j3 r( M! K
; Split on newline (`n)& W2 q* q( n6 }0 h, X$ R+ y
StringSplit, word_array, full_path, `n$ F3 y8 f* v7 L4 K" c2 U
; Take the first element from the array! A( U* f S- q9 ?( w9 e( h
full_path = %word_array1%+ y' Q5 d3 Q! p
; strip to bare address! Q8 ~- ?& j3 Q' g* T" ]
full_path := RegExReplace(full_path, “地址: “, “”)+ ~6 E& l; j* W8 q/ a& s( {
; Just in case – remove all carriage returns (`r)
: `+ D' j$ \! u6 d7 P( p StringReplace, full_path, full_path, `r, , all
+ |# s, H. V6 _5 @ IfInString full_path, \# B9 Y/ ]1 n: T
{
2 u% V& \" b2 t: N2 u* U/ ?$ v Run, cmd /K cd /D “%full_path%”$ x+ ^2 t- \9 y2 B
}
j' ^/ Y' u6 B. ] else/ t. n9 l5 T8 ?/ p' b# h4 _
{
- V4 T3 i: _+ d Run, cmd /K cd /D “C:\ ”
- }/ A( i. {! Q }
( D. ^# w2 ]" _ `3 F }0 i+ N5 K7 c( Z% z& ?) ]
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 p, z4 x7 y9 h$ P$ @6 W: d/ z
这段小代码肯能有两个你需要修改的地方! E, `1 h+ x/ N. w7 y; @/ M& W# a
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) V. g- E, E( I* s/ e( x! P 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 W' [/ c: R" W# \# [ |