此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# x* m. z3 _7 P. ~: g; P4 O; U
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! U) ^" @& c) k; X9 x4 O
方式一:% F, R9 h1 t& c! q9 W" |
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ q5 d/ B+ Y' b* z
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
9 ?8 ?! Q% d/ A n HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
; s1 y& S& i! c1 l 方式二:9 _, w( e5 ~$ L
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 p" ?- z0 x _! ?( t
SetTitleMatchMode RegEx
4 [, g# P7 h& K return* q/ d8 F. K3 j6 y3 C5 I3 i
; Stuff to do when Windows Explorer is open9 ~9 k" Z T* l+ l* o+ f
;
! ^. X/ G* X, m2 p #IfWinActive ahk_class ExploreWClass|CabinetWClass
9 s- i, C* n N% }. M ; open ‘cmd’ in the current directory( K7 G7 E0 l8 F+ l5 ^
;
. Y, ]. s) O* V! x" |! O I4 s #c::
& j y6 Z5 k4 I! |- B3 Y6 c OpenCmdInCurrent()2 r$ L0 C7 M7 i; U/ T
return- w1 v$ s: o, L% g/ \: Z) c
#IfWinActive
3 R _5 C9 z. n3 U8 L9 M1 q2 t ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
- P, W" s0 i- M% r. E: I# N ; Note: expecting to be run when the active window is Explorer.# J$ R0 l5 R; G$ H
;
8 z' U% E" v3 Y7 K6 b8 R OpenCmdInCurrent()
& R2 |* i0 O% n: Z( G {
; O2 Q! E: p9 T& W$ u ; This is required to get the full path of the file from the address bar
j( [6 W9 h* A; P+ u5 [) b/ S WinGetText, full_path, A
8 K( _) V$ H8 x; q- w ; Split on newline (`n)
# m4 k( q P8 o7 Q1 C StringSplit, word_array, full_path, `n3 g: n; w3 b! z2 z
; Take the first element from the array
0 [3 g$ w& F) ^9 P4 O/ N- o9 ^ full_path = %word_array1%2 G A8 F9 C1 I8 h
; strip to bare address
8 ?2 l) h5 @, }4 r2 R$ Y t( t full_path := RegExReplace(full_path, “地址: “, “”)1 s3 i5 s; A+ c: M% \* V
; Just in case – remove all carriage returns (`r)
$ ~( H* u+ ^0 }- X( [3 X- G StringReplace, full_path, full_path, `r, , all
* c; ?% U; b! g9 d9 E7 y& { IfInString full_path, \
) O h# Q- r O9 k5 \3 i {8 H, P" J0 F0 Y, ^* X3 \
Run, cmd /K cd /D “%full_path%”! U) p8 Z4 V0 O3 ?
}
" O" A( _+ j. N$ ^/ ] else
" p2 g4 f5 o: j {7 Y' \; m0 i5 q& f! X+ Y
Run, cmd /K cd /D “C:\ ”
1 L4 p. P1 F- t; c5 n. b }
3 J) j3 O6 {8 d6 t# P% o% X/ v ]& N }' s0 w3 X) A1 v
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
; x; K5 N, _: I6 s" L% N7 n 这段小代码肯能有两个你需要修改的地方
$ A" u& K5 Q* y* |6 w- m 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, I- K! M5 P1 ?8 J 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 S2 R& a3 ?/ U7 X! j8 j2 M |