此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- k- Q) U- m3 ]+ {5 B5 f5 N! k' x 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: v* `5 v' Y9 y* X! R
方式一:
6 `. E$ T4 p6 f 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,5 a* M9 Q3 G, |4 |# W1 R; \
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ P/ V, X/ c) u2 U0 J3 V: {' C
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
: J2 H, w4 E T+ m 方式二:: X5 w& E" z* A" ?9 Z/ N5 o
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 L6 m; r5 P" q( I6 c* o+ \
SetTitleMatchMode RegEx+ b$ y. m- @# K7 Y! b' l/ V
return% d/ u, [* \) C3 N9 J0 w; n( R% H
; Stuff to do when Windows Explorer is open5 {0 D. ~! b, b" ^( M) K
;
. C h$ s9 x8 n' t0 ] #IfWinActive ahk_class ExploreWClass|CabinetWClass3 |, r) @" S7 C; |1 ]3 w! V. i
; open ‘cmd’ in the current directory, T. e/ b# _: r
;
! ` E* @! K7 ]7 u #c::
3 V6 i: `$ N% C' ?9 J! { OpenCmdInCurrent()9 n+ p/ A* g* f- p
return
" x$ K2 M. m1 S, T) f* g #IfWinActive4 d8 j5 V" @" k: }, i: h' D
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.- B: e2 f, `2 q$ m4 |# m! T2 c
; Note: expecting to be run when the active window is Explorer.
( g- _7 |$ T, ?0 ] ;
, R8 c5 ^! ]# Z0 I, P9 a OpenCmdInCurrent()
* L6 w2 K+ r9 d0 S9 ]1 t/ Y& q {" L% x W- Q5 o) b
; This is required to get the full path of the file from the address bar! Q+ ?3 M4 t" x
WinGetText, full_path, A F& _1 L* N3 c1 Z# s
; Split on newline (`n)- V1 Z1 n& R9 J' f
StringSplit, word_array, full_path, `n6 u% ?0 d$ A" t/ _& a
; Take the first element from the array; U7 q _0 m S7 i
full_path = %word_array1%
( o& z1 w) k+ K5 w. e ; strip to bare address
1 M$ Q' b i2 @. ?5 ` full_path := RegExReplace(full_path, “地址: “, “”)
! S! S* A) f7 R6 g% y ; Just in case – remove all carriage returns (`r)
) L6 E4 W2 _& i8 Y- ?4 q) w4 Q StringReplace, full_path, full_path, `r, , all5 z6 O% F$ L1 J" S" S8 L
IfInString full_path, \) p; }0 ~ T9 e& s' L1 T$ W: F
{' u, ~% g- s, ?0 o% Z
Run, cmd /K cd /D “%full_path%”
' F5 c" W3 Z( R' o$ S }
2 @1 F( L! |' ]3 o else
* r) I/ R& l8 p- z$ e3 K) T8 |3 c {
5 Q6 y6 ^! S# j7 B Run, cmd /K cd /D “C:\ ”! e) Q9 E: @: }- L7 r! C& m [
}
+ S- F" ^3 Z. |3 Y$ C9 C }1 b* Y/ d0 ~6 ?; t+ Y/ o
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。, g' z$ j# ?7 Y! [
这段小代码肯能有两个你需要修改的地方7 [2 L. i4 S5 T3 {: R1 I: B: Q- m
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 r6 ^- R) B; p3 c/ u5 l
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. J* p# j0 y; v1 V4 f |