此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& y( F: p; m( L( j5 E7 d3 V 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* ?0 r S7 ~( t8 j1 s# E- A/ B' A
方式一:
* B2 f' R+ h# E* S7 _' ] 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表," A5 ]9 I, f, H4 u/ e$ j
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和+ Z- l3 @) K. L
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。9 k$ O7 v" }' n' a6 [5 ?1 i7 K4 }
方式二:+ W* d+ b* L# T6 w
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:% @4 l+ M: d! k1 I
SetTitleMatchMode RegEx
A9 h l+ G8 Z0 D. Y return
$ h( {8 r2 u+ [2 e) { q ; Stuff to do when Windows Explorer is open
/ j2 ]" i) p1 j/ I' j+ i ; O4 t) B2 _4 S5 G; h
#IfWinActive ahk_class ExploreWClass|CabinetWClass
1 A& P: |: H0 G: w4 n+ _5 e ; open ‘cmd’ in the current directory; b. d, v# [6 F- P: M+ |8 ~' r1 J
;4 u7 V" F8 z+ B
#c::( ~4 f' Q- H( G, Z
OpenCmdInCurrent()+ g; m. G$ F7 L }( { Y, [0 ]
return
( _5 ]5 u0 t3 P# P. [ ? #IfWinActive) m9 A! p- y7 f+ p
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.% |# |& i& T9 d( ?
; Note: expecting to be run when the active window is Explorer.
- l+ B0 H* {( X6 F+ }8 V ; n$ L6 T- z0 s# y5 Q
OpenCmdInCurrent()
4 X* L9 C9 y5 D1 I. W {. v$ o2 _$ y2 l! b! l, r
; This is required to get the full path of the file from the address bar" {9 Z1 w H4 R$ g' D
WinGetText, full_path, A* w0 O9 t" N; _9 m4 c& @
; Split on newline (`n)
; J/ e0 b! l9 S3 p$ R$ k) ] StringSplit, word_array, full_path, `n( |& X1 n' S. r8 X& A: j% G/ G4 Q7 _, e
; Take the first element from the array- Y$ Y4 j3 V5 M8 Z( ?
full_path = %word_array1%' p3 v5 J% C' w$ r! [9 ~ v( ?+ l- k
; strip to bare address3 X( |6 l n/ P; W
full_path := RegExReplace(full_path, “地址: “, “”)8 z* _% m' Z' P1 v% T `4 A2 }& {
; Just in case – remove all carriage returns (`r)
8 M7 R( T& a; B; o StringReplace, full_path, full_path, `r, , all
8 }6 g' Z6 f& g/ F IfInString full_path, \2 `' A7 e1 m1 k+ I, V% }% w
{
. L f/ I5 ~9 x, i Run, cmd /K cd /D “%full_path%”0 [9 _/ V# K4 |! A
}( f- A u. E7 k* W( ]$ z
else4 E9 [4 P" t; v2 ], w
{
! T0 K* F( }1 }5 B" P: y& d Run, cmd /K cd /D “C:\ ”
+ i1 O* A, ^8 w5 |1 ?; i2 Y }& H8 R" }+ e% O( f3 C5 O
}
# Z1 m5 ?, {% L 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
5 i+ u- `* u# S6 q% ^8 Q' Z1 O 这段小代码肯能有两个你需要修改的地方2 z% m+ h! I* m: @$ d
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键" |/ k2 j/ n: T, v" N
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ B( |5 E) U" U9 @$ m |