此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 X3 j! R$ X- T, ?
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 U4 [6 R7 r+ T$ p6 }
方式一:
- _3 W5 s W: p/ _. j 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,. P& T! K/ h6 }' e7 j" s
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! c& ]) W# O3 u4 F0 g+ `- T+ e HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* v3 c8 v7 n. I- v$ s% C2 O 方式二:" K, Z0 i5 a% M) e$ D* j
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
1 m: e3 h, w- o& U SetTitleMatchMode RegEx
! c. R! T' f2 B2 { return
& |) `; y6 F! K- ~. j: t# c; g0 H ; Stuff to do when Windows Explorer is open+ p1 H& S# ~( C' O5 f# i9 E( b) V+ s
;5 U' ~$ A7 I" U/ g" Q+ e9 P8 [+ L
#IfWinActive ahk_class ExploreWClass|CabinetWClass+ e* {/ q' |. L0 L4 T) |1 d& F' n
; open ‘cmd’ in the current directory, M) x: i0 ^8 j% ~. q( s+ V4 s y0 I
;7 f' @/ F* V: p& N
#c::/ D; F. j" u4 ]6 J s& g& J
OpenCmdInCurrent(), w* N7 g/ q1 m! _% S
return
# o$ A6 R0 C2 l/ L' |0 o4 Q #IfWinActive- s3 L/ o& c0 V) C6 \7 [. X
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.7 u% r$ S) W, m! l
; Note: expecting to be run when the active window is Explorer.
5 ~' m: H0 c( a3 l ;
! l9 T$ i' ~) }% d OpenCmdInCurrent()
* S& b$ M- f2 J N6 C/ p5 w {( }8 b* m6 p" d9 P' ?
; This is required to get the full path of the file from the address bar- M6 J( @1 Z: I
WinGetText, full_path, A1 G( c. a( g k* Z" N ^
; Split on newline (`n)/ E4 I$ S( g5 e& p' K- _/ X w; D
StringSplit, word_array, full_path, `n0 \8 G7 r. y7 H/ Z# {& P& e) X
; Take the first element from the array- [/ W9 o. V) b
full_path = %word_array1%
, `7 g& a/ {: T& ]! h3 Z! Y2 j ; strip to bare address
! j g# g: b9 ]$ ^; ~: J full_path := RegExReplace(full_path, “地址: “, “”)
5 L+ e @ A+ Q& Q. w/ j8 k; n ; Just in case – remove all carriage returns (`r)* D, L( H8 r$ n; b ~* }/ b
StringReplace, full_path, full_path, `r, , all
2 M* O7 X, [/ n' P2 M IfInString full_path, \4 p7 H' _' W. K' Z; V' t) f
{
8 {, R# @* E) u0 ?+ `& l Run, cmd /K cd /D “%full_path%”
' y! b7 `( E, M6 x" M, k7 P }0 g, Y) H. t* C0 D) v. L& ?, Y
else
: K B& h) E: X( T4 U E: G$ S {$ c- \1 e; g8 R0 e' k5 G( N, w; Q/ e' T* J
Run, cmd /K cd /D “C:\ ”$ D' L* ^$ X8 Y" ]- r
}1 b7 H6 F; e, B6 D; J6 J s3 W
}' J) ?/ t1 h8 Y4 `$ I
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
, f3 J9 o4 b3 D6 x! k. o5 ^ 这段小代码肯能有两个你需要修改的地方9 y. s5 t2 g' A1 v, i$ e+ k
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 B/ h% J8 t5 z- X* n& ]; ?2 W& Z% Y
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
0 c# T* T! ~# p# s |