此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 a3 F+ @# K4 R6 \& N* ? 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
: _0 z! y# f% a8 R/ J 方式一:$ k# P0 t4 ^2 d0 s% z" i
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
1 \5 v7 j# g& ~7 e8 F( R- ? 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和$ |( x/ G8 p' m4 R7 F
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 q7 |& N" d4 o& H 方式二:
5 s4 i' H, n. j g7 l 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:2 g" Z# R+ S7 J7 h
SetTitleMatchMode RegEx0 P9 Y2 B! I$ a' L
return: D. |( ]+ I3 j% e; l2 `
; Stuff to do when Windows Explorer is open
@ c+ ~. ]! m0 C9 {' V8 t; e ;
p8 Q3 G; `" A" ^) q #IfWinActive ahk_class ExploreWClass|CabinetWClass
" C5 _! u% O1 N- u, m ; open ‘cmd’ in the current directory
5 w c: X8 g7 [* x ;
; a9 t+ ]6 ?4 j3 t2 S9 k7 N9 C #c::
( s1 g. B6 e' r# I OpenCmdInCurrent()
1 |7 M! V x2 s) p1 m5 u9 n+ ? return
5 L* }/ X9 x6 Q& v7 u6 E: R #IfWinActive
& c# ~, x- l+ i: ?, F: p6 T ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 l+ R4 e2 W* d) i2 k2 ~ ; Note: expecting to be run when the active window is Explorer.1 I. l0 T, Q- e1 p7 |- G) v
;
! ]( h) e J. e OpenCmdInCurrent()% j) V5 |; p5 x8 e, z( P
{
/ A( n# Q3 A% g/ C' o! Y5 K/ q ; This is required to get the full path of the file from the address bar
) O) w: F$ y7 e( o WinGetText, full_path, A% ~0 {+ @" o4 |8 b# {: Y; k3 Q) s
; Split on newline (`n)
, @( M3 d# r! m- { StringSplit, word_array, full_path, `n% d5 ^' @; |. ^$ C. _; v/ W
; Take the first element from the array5 U) W. t1 I0 y. X. G( O9 \' g& r
full_path = %word_array1%
2 [+ z% G5 L! p& l. X( f A' L ; strip to bare address$ r/ X8 h# g" Q% s1 \
full_path := RegExReplace(full_path, “地址: “, “”)4 W! j' }7 n, Z- R( Z
; Just in case – remove all carriage returns (`r)3 d) i0 F. R- \' \* s
StringReplace, full_path, full_path, `r, , all, A9 t' W- j" _
IfInString full_path, \
$ `; Y- t ~) J- t# o/ L M {
' T, A% a3 Y9 K) l7 J Run, cmd /K cd /D “%full_path%”
2 D6 z7 d& v' E1 q; S }
) ^, e$ J2 O) l; K else
9 w$ l- H P2 A4 | z; m7 p [5 a {
% U7 ?; D" |: g! u! y; \ Run, cmd /K cd /D “C:\ ”
* ?7 A9 D6 s | }) ^, L! A9 b9 x$ t+ p2 o/ j: U. L% e
}
2 o) t* f( ~& ^, B. e2 `2 C* h- N 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。. x' m7 P( |) K% C1 C
这段小代码肯能有两个你需要修改的地方
5 k* H# T% a& M) b, M 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键/ G0 |/ {, F+ R8 t
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ F( i. L3 b( L8 f, x0 b |