此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ r- g; ?+ [" |# `( P P
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ k2 ^/ @: I) b) ~; F 方式一:! R/ s i+ j) s, k% j. k3 b/ X
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
/ c% z2 m- N# X# i( m3 X3 W( t 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和0 R! p9 |: [; n' W& Y) v7 t
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 g; A/ |6 s* H, y6 ^4 W, u! D
方式二:
" C+ Q! {4 S9 G4 F* V 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:8 x3 w$ A. ?: C# v/ w2 u
SetTitleMatchMode RegEx$ e& v4 H- T: Y
return [5 ~8 S ^) D6 e, }
; Stuff to do when Windows Explorer is open
4 x% J$ D" J1 V! J. F. { ;
4 W' h* E, P5 J" H5 m5 b8 {. z- M# F #IfWinActive ahk_class ExploreWClass|CabinetWClass7 i; U Z' v2 } R7 r9 _
; open ‘cmd’ in the current directory% h/ B7 R2 A2 t
;8 g+ E$ m' B( d+ j; V
#c::
' Q: Z8 w/ V0 O N OpenCmdInCurrent()6 s; v9 o* L. C+ T
return5 {7 m; Z& K/ g' Q s, R
#IfWinActive
5 x- m6 ^9 t6 `" Y0 S ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
" b: H0 o z, C k7 z+ P ; Note: expecting to be run when the active window is Explorer.
) ]4 \7 F- w: ?5 O9 u ; ]1 e7 i/ U/ }# j
OpenCmdInCurrent()
3 n4 e7 {1 B6 I* }6 P* | {
8 R0 j) z& k, f5 M' r' }: Y% | ; This is required to get the full path of the file from the address bar9 n% Q/ s* s% b" C* g) e8 g p# ~! u
WinGetText, full_path, A
& U" J" C' a% p5 b5 C& Y ; Split on newline (`n)
! ~$ ]; R7 R7 m, |2 S, |% a StringSplit, word_array, full_path, `n
2 g; R! u2 `: Z3 G1 o$ {4 n# p ; Take the first element from the array
l3 ?" b4 r4 o, P full_path = %word_array1%: a6 C+ o) K/ F: V) ]: u/ \
; strip to bare address" n# H! ^0 V! d! V5 B
full_path := RegExReplace(full_path, “地址: “, “”)- c& p3 \, Z" }7 x) @, S
; Just in case – remove all carriage returns (`r)
- r$ M9 C/ ^4 u# O+ U( A* l StringReplace, full_path, full_path, `r, , all& W5 \6 g9 z% J( p$ i- Q
IfInString full_path, \- Q2 H8 Y' G" P/ P: A! f
{
$ s2 I. Z6 [" y Run, cmd /K cd /D “%full_path%”8 O! u) p6 J: I: C6 I6 G
}
. k- R1 ^9 b, F else/ n" S1 k x* e
{
/ r) E5 A0 z+ U+ s5 `/ n A' S4 D Run, cmd /K cd /D “C:\ ”
+ \" P3 K4 w$ U: z% E }& |4 M2 |, {" y# v
}4 s; u- V8 Z/ n6 h) `& Z8 H8 x
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
J& R% d8 I3 f! v! v 这段小代码肯能有两个你需要修改的地方, a) f+ R! d- N9 o% Q+ H5 H. c8 Q2 L
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. I* i0 v+ \) l( a 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
H5 i5 D# A0 } |