此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) `" `' J6 M. J/ _9 V o) X
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 J! e9 m9 f6 |1 I" _
方式一:$ A# Q+ `0 w: \: Y& A7 v8 v
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,7 G5 G5 ~1 B$ e+ w
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' k# i, K- a9 z7 `% M* k
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" I8 R! A& Y. ]2 x 方式二:3 I' L8 ?. A: e5 Y/ H0 S
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 `% w$ A1 C# B" V0 ?
SetTitleMatchMode RegEx; d7 `4 \4 _' i
return
l( T; l0 r% q0 S ; Stuff to do when Windows Explorer is open' t) Z# L' F) n' _* s) }
;
$ k3 C6 R7 E4 {* B; C% x, [ #IfWinActive ahk_class ExploreWClass|CabinetWClass9 x5 \- t" y1 w+ a' c
; open ‘cmd’ in the current directory& S8 N0 c! Z! I& m/ d6 V; B3 i; p) y
;$ {. \3 ~. r# g. }7 a2 Y
#c::
1 k6 Q' \6 s( z! j+ M OpenCmdInCurrent()+ `- S( r( m% \. T) x, O
return% t5 w5 D/ g6 O6 x9 e; B- z3 @
#IfWinActive* r8 V+ D. M% V+ B
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
, R8 [1 ~ T# U) _9 i; p. N ; Note: expecting to be run when the active window is Explorer.( S5 U& @" w! m) T* }# ^4 @" N; j
;. f3 S* T c0 ?& o
OpenCmdInCurrent()
' ~6 U9 ^5 @& f) e7 f( L7 E, X- o {, ?- @4 L( B6 l# Q7 v
; This is required to get the full path of the file from the address bar0 F5 g3 E$ Q+ f5 ]- z D' t
WinGetText, full_path, A6 n7 f' k; [% k$ `* U5 m x
; Split on newline (`n)
/ y2 I- o/ t7 Z" V' {/ C StringSplit, word_array, full_path, `n
1 ], g- } u' @0 F+ `3 u ; Take the first element from the array0 d' V- j3 B' ?8 ` s7 o( C! C) ~: s
full_path = %word_array1%& | J6 Z7 A7 ], Z9 B
; strip to bare address
; @$ V8 _8 \7 k( k m1 H | full_path := RegExReplace(full_path, “地址: “, “”)4 B/ L7 U$ F, U7 b$ a
; Just in case – remove all carriage returns (`r)# d) A u% R& j. J0 l3 _: a( F
StringReplace, full_path, full_path, `r, , all
8 Z) F Y' D2 z, V- ]4 ~" G* ` IfInString full_path, \; a: ^; b- [8 S
{
" f, J- l; @5 E7 { Run, cmd /K cd /D “%full_path%”8 A( ^+ I' o) |# s% N4 |
}
' C. \ }% Y7 V! ^% o7 l$ D8 W else( A4 J. ^8 u/ `1 a# [7 o/ }
{
0 L5 I- |& ?7 u- {1 j Run, cmd /K cd /D “C:\ ”
' t# y c2 I: u) A: {' ]- A# {( J }- m/ s3 T* ]* F! m% F Q
}
% Q# Q4 G" t7 y, M! [7 j4 N" Q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* X# N! c1 J7 _6 i7 P. d8 o
这段小代码肯能有两个你需要修改的地方
+ j4 R) ~/ w9 Y: g/ Y9 q 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 B6 K$ A4 p+ J
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “- t: t* O% y( u! d3 O% i% g/ R
|