此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 O% X" }, ?% J0 F
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, U& p/ P: A/ h& |; A 方式一:: [. h: T0 Q) l( N1 s8 s9 Z D3 F5 N
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,& p# `, e5 A8 ]1 d4 g
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 s# p2 v* S$ P$ J HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 G4 F3 s2 l# O7 j 方式二:
4 O1 M/ O( \; S+ |) | 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
, }/ Q! s$ ~2 N O, O7 s0 d' } SetTitleMatchMode RegEx7 w0 C. @( y* L3 ^4 s
return
! M6 x/ b$ W# {- G/ C5 Y9 M( F, p ; Stuff to do when Windows Explorer is open( X2 Q4 ?4 a8 _
;- K: T4 e1 z/ n$ r$ p: @- O
#IfWinActive ahk_class ExploreWClass|CabinetWClass
' h+ O7 [5 [8 f/ f$ E t1 N9 k7 I ; open ‘cmd’ in the current directory$ g! n8 `: `2 Y/ c, g7 |5 c
;. }0 F) z' M; F9 g/ | w% Q; \! m# J
#c::6 Y% V5 P+ w$ m \
OpenCmdInCurrent()+ J! M4 y- X( h, F5 s8 \$ W+ N
return" M( @# s- k- h
#IfWinActive
9 s& \' E- w/ U2 I) z3 r ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: E4 i0 r, r$ m$ F! ^" v; Q3 S ; Note: expecting to be run when the active window is Explorer.. K& x6 h2 ?: z7 @- I% m8 B
;* d/ i' X: C, ^$ S" B3 W' b
OpenCmdInCurrent()5 w- J& y! z; D$ i! B2 z" L
{9 D2 L h) Y! k) ]; j9 N
; This is required to get the full path of the file from the address bar
0 {2 y( E, ~8 J( e$ U% A6 k WinGetText, full_path, A/ a! |' a! d2 P, K# ^/ B5 M- e
; Split on newline (`n)% ]5 P4 Z0 m2 m4 z2 u5 C/ j& x! S
StringSplit, word_array, full_path, `n& u4 \' S' |2 `$ s) @/ L
; Take the first element from the array
, Q& i4 H+ [- S+ K full_path = %word_array1%
$ N6 z# P# }8 h& F" p1 @ ; strip to bare address7 U# B& y7 }6 }
full_path := RegExReplace(full_path, “地址: “, “”)( g/ `8 D" r4 A1 I6 b. J& t; x
; Just in case – remove all carriage returns (`r)
' G/ _. B( S6 w5 h6 p: | StringReplace, full_path, full_path, `r, , all' s) b4 P( c+ Q; ?* s a9 n* a
IfInString full_path, \. i9 ]' R" q, y
{- Y" w, G8 J* o) q
Run, cmd /K cd /D “%full_path%”6 v9 d) J- f( I: m+ G
}" V+ E( o) [+ I
else
! ?. E, M# n0 h) }1 o9 `+ g2 l {
: v7 }( D" B; N0 A% Z! _ Run, cmd /K cd /D “C:\ ”( z0 c7 N" y1 T, V# c
}
: L6 \( N. p( W' W3 C7 e( R }
1 o6 H! @/ `4 ~9 e8 V 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# e1 k$ A8 w$ u$ W5 Z. y 这段小代码肯能有两个你需要修改的地方
& P9 [% i# ~7 [: K# Z: ^! W. C1 ~ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( A" P3 F6 v$ j! I 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 k1 ` y1 ~: ^' _+ A
|