此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
" S7 s" F+ l& Z2 C 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。/ X1 j& L; `: N( i7 k5 ?
方式一:6 D) a9 v( H2 b i7 A0 |
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# ]) u8 F- I" @) J6 I 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
+ k* c M8 h& [ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
; V6 v! Q: _# J3 l 方式二:
$ ^; b0 a) }& ]* q 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:/ u2 V5 N/ b3 @) H$ P$ B
SetTitleMatchMode RegEx" _5 A) E4 l) Y
return0 V) |" R2 z9 S; j5 R
; Stuff to do when Windows Explorer is open: @5 e1 g: i5 n/ d, P/ g
;
; A) N7 m! G" J0 ?" j3 O #IfWinActive ahk_class ExploreWClass|CabinetWClass1 V) r; m9 _; m. j/ h) c2 }
; open ‘cmd’ in the current directory" I( P5 }/ t# P& ~( K
;
- t, i+ \5 ] u) h #c::
0 {# L2 E( t( s# | OpenCmdInCurrent()
; Y8 v K$ T9 Z$ _9 y return0 g% \0 f# |! K3 ^7 \9 w
#IfWinActive* m- M5 B* q$ x2 x
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) I x7 _! b0 m ; Note: expecting to be run when the active window is Explorer.( H8 U9 z! q" i+ \
;
q% @8 D8 t% u% {9 W OpenCmdInCurrent()
7 y6 i6 _- p, W/ }" F% W7 L {' t) l+ @' S5 A# [
; This is required to get the full path of the file from the address bar
+ A# Q1 O* `4 N6 q& m0 o WinGetText, full_path, A& a8 w2 K- W! r$ ~& G9 q) ?
; Split on newline (`n)
% C1 L1 @/ N# L StringSplit, word_array, full_path, `n' y/ {' e& G: O# e: |
; Take the first element from the array
4 y d- }1 `' h# c9 J/ M( A8 s; C0 _ full_path = %word_array1%6 O) L1 c' J. `% ?1 [8 Z
; strip to bare address
# h& R6 c) F1 T, n' }5 l. M full_path := RegExReplace(full_path, “地址: “, “”)6 V% D# ]& f4 G& z) Q; x
; Just in case – remove all carriage returns (`r)2 H5 J1 |8 ]) B( @/ _4 a
StringReplace, full_path, full_path, `r, , all9 U/ q2 x4 U+ G/ J% s* X8 h8 [, i
IfInString full_path, \: d( u8 ~3 }' n: B/ j
{$ ]/ N7 |( k4 {" @
Run, cmd /K cd /D “%full_path%”" w! R8 [+ D2 M) D. X
}
& B t6 | O" ~$ ?6 v' n else
& m' ?$ o7 E8 P1 R) ` {; h' f6 [# v8 Z5 Z9 b; ]) }6 o
Run, cmd /K cd /D “C:\ ” f# N5 X" v( I+ i" L, I
}0 b5 `6 z% H1 z3 `
}
; d( s5 C6 }& J2 F; w0 W% r2 }8 Z 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 ?* _% Q" Y. y! w/ G' R8 b
这段小代码肯能有两个你需要修改的地方
2 c, p* j$ n7 }9 i% { 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
6 E, L7 P( k& B+ L5 p 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
6 D$ ?6 J5 S, e$ F |