此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。! i6 x5 R+ ^5 [- I9 R- ?
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 U8 Z3 N4 M( d9 }
方式一:
4 N9 d9 _: G2 o- q 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
L: G2 ^6 K, |% N1 T- ? 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 }' E/ t B# m8 P8 a HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 b s7 i9 W& v/ g/ c
方式二:- P- B- u, v# t' _. K$ L
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& u% a. L6 D" p: H% \5 C, m& e0 x SetTitleMatchMode RegEx
% t: R9 W" G% M% O9 A3 ]2 C return( V; I1 [. {6 ?& }. s6 D4 g
; Stuff to do when Windows Explorer is open
. ?# I; o0 `! W p ;+ S" F+ k6 l, B) |
#IfWinActive ahk_class ExploreWClass|CabinetWClass
7 o) B# _6 K# {2 o( `( T ; open ‘cmd’ in the current directory, B/ N J- e1 e i) X; P' _
; a' q5 G4 _" W" s- W! }
#c::
}1 d( ]- @6 ~$ H5 J OpenCmdInCurrent()* K2 A: E! {6 k
return/ l3 @ U) V# w6 O6 N
#IfWinActive9 e$ ]) u/ I) G! w1 h1 {% X
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* w) S% Q1 K0 ?0 _8 }3 P ; Note: expecting to be run when the active window is Explorer.
{7 w' e8 z/ y, s' Z ;
. m! W5 O# W) w0 Y+ l6 T7 z3 ~ OpenCmdInCurrent() K' i% i1 r# d* z
{
1 b# c/ M2 L& F2 I8 z ; This is required to get the full path of the file from the address bar
' h* l2 e1 y0 m! Y9 A WinGetText, full_path, A4 H9 o8 w) b3 p- Q$ |
; Split on newline (`n)7 j; `, x; p; O+ r
StringSplit, word_array, full_path, `n& _$ C( N! i8 L9 i6 O! W0 U8 \, ]
; Take the first element from the array
3 v& y7 U& U' \0 @7 n" d full_path = %word_array1%& n1 ?4 e& R3 v2 q* ]
; strip to bare address
& f: q. k/ T, N8 B% H) O% e full_path := RegExReplace(full_path, “地址: “, “”)
* y* w) }. h* O ; Just in case – remove all carriage returns (`r)( U5 R' P7 ~$ w) `1 U Z
StringReplace, full_path, full_path, `r, , all
) M1 L% l% Y; u$ S/ r. Q/ B1 \ IfInString full_path, \
: G- \6 J; }# |' p6 Y: a% @ {5 b7 X$ s" T% ~+ \! [* {& m6 ]
Run, cmd /K cd /D “%full_path%”
. Y7 N( A8 o0 w R) U9 N Z: h }+ D4 I, T' k6 L5 M1 P, T
else
5 q+ ?. `, M9 h- c3 Y {
% K8 \' h" [2 y1 Z* ^3 S Run, cmd /K cd /D “C:\ ”
5 Q1 O& \6 Z2 I+ v) I }! t: i- M, w8 C h$ ?
}7 u d6 z7 K# _) F% s" D) E) A9 Y
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* w; l+ D4 h: t( ]0 A
这段小代码肯能有两个你需要修改的地方
$ l; R6 n/ p* |: }/ w% V/ R 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; J. n& {: j1 u8 q( T) E, p" l0 ?+ u
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
% i4 M- P; W2 Y. b( K2 C0 l |