此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。5 ^6 C3 I& s5 \$ W9 h
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* O! B6 T+ l# N5 S' ? 方式一:% a; C& ]0 q! {% A
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,! _7 B- Z- ^9 a1 N5 V
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
' Y2 P5 U4 G3 J HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
8 A, Z' D) S A5 b( q A 方式二:$ [- k( U+ j) |& P8 f
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: Z0 C+ Z( K/ y0 L$ P) }& t: A
SetTitleMatchMode RegEx+ V* l: a9 r$ | z0 ^/ Z1 t. W
return# A" ]4 _5 f, V6 Z: X( p2 r$ y
; Stuff to do when Windows Explorer is open
/ \- Y: E' n" h8 n( d/ @ ;
# ~( G" K) j/ Q" y$ Z% i% ^+ ^" F4 h #IfWinActive ahk_class ExploreWClass|CabinetWClass
0 G8 R( o* T, J ; open ‘cmd’ in the current directory
) s: |+ ~# k: m ;
' G$ f% C8 o/ Z' ]; ?/ | #c::
H6 M& d" f2 W+ k& `) h5 R) ? OpenCmdInCurrent()- r2 ^3 o' q& r1 ^* u ?- W
return! S7 L( Y/ Q; ~$ d& ?7 }, x
#IfWinActive
" t' n) x$ J1 J: B" N; [ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) t8 P+ X, `4 A3 p8 \! [: P, M
; Note: expecting to be run when the active window is Explorer.
$ u% g/ J7 Y! e6 b/ Y; S ;
; N* f; m/ o, K* Q, p, n5 t OpenCmdInCurrent()' H- l5 R1 C5 k3 L6 p: C
{: Z: ~0 V V4 \# w* N. _
; This is required to get the full path of the file from the address bar' l* ^( ]5 n6 X7 @6 {/ L
WinGetText, full_path, A
7 Z- {, i; [" ]$ z5 H ; Split on newline (`n)8 e9 g+ d$ t/ c. T0 r
StringSplit, word_array, full_path, `n2 A* c2 D" S9 B( d
; Take the first element from the array
8 C8 C& W- L# {+ d full_path = %word_array1%4 T% t" {9 {7 q9 D/ h+ k
; strip to bare address" ?! N! Q* d, Y1 i
full_path := RegExReplace(full_path, “地址: “, “”)
# T8 w, a* @: O4 m' p/ I& ]& Y ; Just in case – remove all carriage returns (`r)
$ \' ~& Z. y/ r StringReplace, full_path, full_path, `r, , all
3 Z9 T) @4 f5 S' y. d IfInString full_path, \
8 t- S1 ~( U5 A) Q {8 w' l, r5 A( E4 l! z8 Y" C c
Run, cmd /K cd /D “%full_path%”6 `& a; r5 n. E" w0 V
}; T% |# A0 W' N/ G: o
else1 o( u" N- g" z; d, b% u
{
! P7 B, Z) A% k3 V# n8 w) r, w2 M Run, cmd /K cd /D “C:\ ”
5 k2 z6 b$ B* i' n/ }( F }% Z; g0 b- T& z9 E e
}
, k+ \. b. O9 ^+ y1 z7 {" g" X 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。5 g) A' V ~3 F0 T: ?/ D" y4 ~
这段小代码肯能有两个你需要修改的地方 h. s1 S! v; ?( m& { q
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 Y1 t5 O4 i$ }* g; \. h0 {$ C' l 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 F% e( S! P; ?; o+ H I" l. E5 O
|