此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 y: _$ j# I6 }- K n) g
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。/ { l7 Q# K6 G4 A
方式一:7 y1 n, W& l [ C5 l- L9 }
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
v; i% w" ~& x% M8 r: o `$ w. {3 D 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 g$ o! A U7 _ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。 _! g n+ J/ Q T J; ]
方式二:- ^! l$ Q* A! e# [7 {0 _9 Y0 c
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! X# T, f$ K: B5 y* _7 D0 o0 c
SetTitleMatchMode RegEx8 `% u# w0 |7 Y2 d8 o1 p1 y
return; Z! P0 Y% g8 W2 o
; Stuff to do when Windows Explorer is open; _; @$ a4 [8 R9 H% P
;
7 b: r2 l4 X9 W% D) A" U# Z #IfWinActive ahk_class ExploreWClass|CabinetWClass9 B1 y' }- I8 m' I
; open ‘cmd’ in the current directory
7 n) [5 r! J$ y ~& u& J ;
! [6 O3 }2 M/ j7 d0 O #c::; b0 z V! h( Y% C9 h7 p
OpenCmdInCurrent()" W; R/ ^8 `2 C: a
return
8 k8 r0 ~4 g. E; n #IfWinActive4 U& d* l; \0 @! u6 O
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 |- K# J" A7 {$ z! j ; Note: expecting to be run when the active window is Explorer.* M/ k2 E5 x2 M% Y2 G
;# N( T f( j( O3 b& U7 A5 {0 q
OpenCmdInCurrent()9 f" i$ M" @* t4 R0 h
{
8 m2 G5 x! N' D6 [. @ p' b ; This is required to get the full path of the file from the address bar }. L# P2 |6 `+ f) f
WinGetText, full_path, A
; P: I4 M9 s; O ; Split on newline (`n)
: F, h6 H& E, ]3 B StringSplit, word_array, full_path, `n
, ^/ k% {/ n2 K# o: Q- t ; Take the first element from the array! K! U- Z( o8 L2 v) d2 r$ P0 t
full_path = %word_array1%
5 R5 x. R- x" Y( V" _0 I$ u3 k: [. K ; strip to bare address
7 w3 _" a* ]2 y# C/ P s. x6 l full_path := RegExReplace(full_path, “地址: “, “”)1 b& a! k* i! _# x8 G. }
; Just in case – remove all carriage returns (`r)
) ]6 r+ u. Z7 O& S% t StringReplace, full_path, full_path, `r, , all' p+ Y0 w( O3 W% _
IfInString full_path, \
* A) i% {* S6 B5 e$ M9 h! O {
" }$ {1 ]! [3 ?1 E; L8 k Run, cmd /K cd /D “%full_path%”$ u$ t2 i' i% r$ D8 q `+ {& v
}
) [4 B( O, Q% [( N else
* T' E) }3 r! m# a" ^; \# Q; Q( N' k) @ {8 g* r1 C# g( D: V' R
Run, cmd /K cd /D “C:\ ”
1 _+ C# z5 r* x5 x) F/ Q }7 s7 Y: |1 y8 V
}
' H, x2 b2 R' x8 }9 \5 g5 ~ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: w7 g; R& k3 J, T6 m8 I0 S4 b8 U 这段小代码肯能有两个你需要修改的地方
. h- V# r, Q- l+ i4 y0 W 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 [& F. \+ Q# q2 c( ~
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* A. E' M% ^4 f4 X' ~3 M$ l) x |