此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 m* _ h/ D: E' \" I8 m+ F
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。; \" I: i% {$ h5 |" }& f" i
方式一:. H w, d Q- d3 d* N% o# N* B
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% f, |+ y3 W" B! D# x" _. v1 A 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ e, B& s, M: ^* _1 ?5 U HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 b4 Z7 t" X& X6 W 方式二:
# Q2 E+ |5 y$ Z: @$ E 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& h8 C5 j+ Z/ @0 I; G1 | SetTitleMatchMode RegEx+ ?% ^1 s4 E3 s, s" Y
return) L. N8 n: V3 U/ j0 X+ K
; Stuff to do when Windows Explorer is open
& [7 G* k2 f2 |- b1 t ;
& ~: V6 z$ x- |/ s3 {8 b #IfWinActive ahk_class ExploreWClass|CabinetWClass3 @: o7 H$ o/ J
; open ‘cmd’ in the current directory8 `# I/ s8 g6 \2 {
;
2 s+ Y* Z1 [% K; j! @ #c::3 R {( b% D) v
OpenCmdInCurrent()6 ]5 Q) U0 N1 S) I
return
1 p. D5 |# V. ^) b #IfWinActive8 F4 Y" K% m6 L7 V5 i
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.* v4 s% V2 @+ {& B1 f5 l! Y) ?
; Note: expecting to be run when the active window is Explorer.4 y: f, b J1 u' ?
;. K% M t z3 S* f1 y9 _6 P
OpenCmdInCurrent()
4 W a5 ]9 ~. d9 s D# n+ s {- q7 ^- W3 Y& C; P& S" O; ^" W
; This is required to get the full path of the file from the address bar
0 {! x/ g; o( V8 c; I6 r WinGetText, full_path, A
& j; D& j, o5 ~8 E/ |% i; k; \7 u ; Split on newline (`n)
7 z, l! ~/ b6 G, k0 Q7 s7 F StringSplit, word_array, full_path, `n
2 h& o0 E' d( Z! v# E, h ; Take the first element from the array
$ C1 f7 K2 S% }7 F7 e full_path = %word_array1%
1 E& X" }" M2 ]0 Y. T+ u! K& y ; strip to bare address0 U2 @/ d# @$ n v' T8 H& w
full_path := RegExReplace(full_path, “地址: “, “”)
9 E' B8 }. D0 ~, O: q ; Just in case – remove all carriage returns (`r)
: `' ~7 l$ O, D A" w, e) U) R2 f' o StringReplace, full_path, full_path, `r, , all
* F! p$ |6 ?( U. _7 h2 t: L IfInString full_path, \3 y. F9 _* W% O4 x3 N) O
{
- C! n, n7 \7 ^# a Run, cmd /K cd /D “%full_path%”1 @1 z1 g8 ~0 N, h' A5 w
}8 ^5 N$ ~" k' h9 T
else
& p" D1 g- O8 V ]) [! c7 x8 j {
6 d5 `# I' P" }) w" V Run, cmd /K cd /D “C:\ ”& _+ f }. w3 O3 r
}- V! h% [4 ^7 l; ?8 n& [: s1 N
}
' X) W( |8 |, ~- f 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 ~* K' r8 X" p! i( P# N, w0 t& |# u 这段小代码肯能有两个你需要修改的地方
$ Q3 V- U: \- u Z% Q$ f( Y 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 G" C# C( K; x1 K 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* N" ^; x, R2 L3 K6 c |