此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
* g8 Q. K* z' o+ G( p 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 I( I9 x: X% n/ i7 b9 ?# k 方式一: v8 `* x2 A! X
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
0 v: ]# r/ x7 s' [- s0 M 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 R9 {( E4 c3 r" R8 n# u HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。. p: N5 }* y9 V: @8 Q
方式二:
: f/ f e' l( _! _# L 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
, V( `0 l T' C SetTitleMatchMode RegEx
8 g$ {& x8 g! m" L I0 U2 s return
/ H/ G& p. c1 Z$ f3 [0 W ; Stuff to do when Windows Explorer is open" O/ W3 _2 G, [1 k& Z! F
;: i+ U1 s( _9 X3 G* }! x
#IfWinActive ahk_class ExploreWClass|CabinetWClass3 T5 J. O h Z6 n
; open ‘cmd’ in the current directory
$ o/ Z; T% ?" `3 c/ e ;
+ V; O( v+ q. |5 P7 E #c::
+ Y7 h9 G! U1 x/ g OpenCmdInCurrent()
1 B0 Y7 D+ S- s* z/ b return
* ~6 B, _! R( v9 [ #IfWinActive+ p M2 a- x: t* H
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.6 S# S7 n; ~: ~3 K0 e% j& O% f3 [
; Note: expecting to be run when the active window is Explorer.
0 M3 C- c! i* \' ~% l. `3 R ;8 G: g" W; y+ V8 K7 C
OpenCmdInCurrent()6 t8 a) V: r# r6 r g# T
{ [4 ~4 \3 _! | m( B
; This is required to get the full path of the file from the address bar
: W3 `6 W! J% [ e4 w WinGetText, full_path, A
4 C1 j7 G2 ?* }" e( L& _$ i ; Split on newline (`n)
/ M/ j2 [& P i* W StringSplit, word_array, full_path, `n
2 r" \; c% Q" A0 y* z! X ; Take the first element from the array
; k( }; h$ i# C full_path = %word_array1%4 B3 Q7 ]) C& p0 @" d
; strip to bare address. u3 h6 i- `4 u {: x, v
full_path := RegExReplace(full_path, “地址: “, “”)5 m- ] D) H4 @! m
; Just in case – remove all carriage returns (`r)0 d2 `# x! U1 o, f& m7 P
StringReplace, full_path, full_path, `r, , all
7 T+ P& I5 ]- L IfInString full_path, \- O, R. {6 h8 z, [
{
0 R3 a. T2 j' l( m. _: E# O Run, cmd /K cd /D “%full_path%”6 v) l- y/ M+ u% H% y8 M
}5 K G+ P# {: A/ b# z, B: W
else
1 ]% w3 j- N% Z: _8 o: R) D+ i {
9 @# p z3 P( S" J( Z Run, cmd /K cd /D “C:\ ” I4 b; E; F5 h) b, Q, r
}5 f/ d4 B# W' ^3 s2 E% p4 S
}# h# g7 [! l& z, B# j( m) w9 j
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: o3 b$ h2 U# c& A3 m' _1 l 这段小代码肯能有两个你需要修改的地方" A1 ]+ m: I6 {, E2 j
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 H% W( f) R0 [: ]
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" V3 k* G. r/ H- ~* Z |