此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
* g3 }7 ~# E" ]" C 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。# z4 T& K8 e% h- D1 L, Y# `% { i6 |
方式一: @7 g- l0 v& W
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
$ D/ K# p* T# B2 n 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 X1 s. _- I$ ]9 O' h" c5 K V HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 N y8 s3 |, a; }- D% G j 方式二:
( r% g& a* g2 A" }' z! \5 m 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 m0 R9 Z! q% O! a SetTitleMatchMode RegEx
+ q4 ]9 F1 O7 L return7 u/ s# u5 D& Y& p0 @- r# _
; Stuff to do when Windows Explorer is open
* t9 l. j1 g3 u+ M& x9 F ;
8 Q# N# H/ A" ^/ h% i+ G #IfWinActive ahk_class ExploreWClass|CabinetWClass: L- N2 i. C- U* o
; open ‘cmd’ in the current directory0 O$ R& n/ ]& E$ ]
;2 y3 K8 t: W# `( A2 ?3 W
#c::( {8 ?2 q: T. i/ U- B
OpenCmdInCurrent()
4 W' ^6 }) u6 P# `; X return. ]+ t% Z8 j, j, R
#IfWinActive* W" t0 E" P) D) d
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' X5 e3 x0 E" o1 L j7 J9 F! P& K ; Note: expecting to be run when the active window is Explorer., o2 j8 b( w/ j# b" _
;, k* g$ G% h. H* t+ S! I7 D) X
OpenCmdInCurrent()1 |5 H- R8 h; x/ d* x# G
{
) `' m- W _* D8 ~ U ; This is required to get the full path of the file from the address bar* V X8 p( @0 J. J
WinGetText, full_path, A; K- O. y9 ?0 n, b+ p
; Split on newline (`n)7 l( h& u' n8 V8 i+ o! [
StringSplit, word_array, full_path, `n$ l* u- o. x5 m
; Take the first element from the array$ g3 U* p- ]9 E+ j
full_path = %word_array1%
5 D, A* y$ c5 o6 E+ W5 y# {: N ; strip to bare address0 ^3 N3 P7 R0 `, f+ b
full_path := RegExReplace(full_path, “地址: “, “”) d4 ?+ Y1 c! D( ?; N
; Just in case – remove all carriage returns (`r)
+ C$ ? h, l' S: O StringReplace, full_path, full_path, `r, , all
$ v2 { K+ M9 W0 |1 J IfInString full_path, \
x- B U4 b2 z8 A {' s3 s) A. V0 ~
Run, cmd /K cd /D “%full_path%”$ `- |$ S0 A L
}
! x8 }- X+ ~/ Y4 V9 h- j6 `/ F2 J" Y else
3 U* `. G0 j% R4 t# Q! e/ W, S {1 t4 s& ]1 c0 b4 k
Run, cmd /K cd /D “C:\ ”
9 j. H P0 }# K$ b }
8 ?1 S# i/ g3 [8 b* T }# X6 c/ ^& s) [1 Y1 U2 F- X, E
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。; t' E! O. G2 S5 f
这段小代码肯能有两个你需要修改的地方
: t( K g5 k& X 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' O( A$ o$ a3 J3 \: [3 {6 Z* u 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “- ^, q: m1 u& T& F# P2 \
|