此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ e* C+ N* Y" x( k- Y2 j
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 S$ a6 k3 q+ a/ q# g# ?+ A
方式一:) r- T# e7 M4 N" S+ G1 g. k' H2 z
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,! C$ a1 e8 Y" F# v) E
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! X& Q+ \ u3 W$ t8 X% e HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。% ?" u: h7 ~* }6 [
方式二:5 e+ m/ S- Y& Q6 r: k1 S
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:) ]8 D/ |( B% W8 t7 {7 g# C
SetTitleMatchMode RegEx6 ~: s8 S5 z# C. [0 _: I+ q/ j
return
. V& j" T: v/ F9 d0 v# ` G ; Stuff to do when Windows Explorer is open
& }8 J$ m4 d/ @ ;1 J+ i3 w3 Z; e$ l# x* @
#IfWinActive ahk_class ExploreWClass|CabinetWClass
" W: j& s3 U1 u7 G& I' X ; open ‘cmd’ in the current directory+ V& ~& p$ [& G/ z# p
;
^9 ?2 i Q, [% v3 { #c::
3 h0 d5 e$ n1 Y1 ^ OpenCmdInCurrent()- P* P, K9 O/ }% ^# f3 D0 ]( k5 f: M
return6 L" y. Q" R6 H8 T* C9 f
#IfWinActive9 E) A* f- u" `: C2 n2 O
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* N( w. T- [9 P) k$ H* |3 v: I& [ ; Note: expecting to be run when the active window is Explorer.
0 |7 m6 s: o( @0 Q" h ;
& S& a- Y4 Z* o p/ @. e6 H OpenCmdInCurrent()% t. X4 [, {# I& p! g; J# x/ f5 B6 d
{4 {# O9 M6 b% e3 O
; This is required to get the full path of the file from the address bar
1 z4 g) Z7 o% v! z; o WinGetText, full_path, A
6 h8 A, \$ `8 N9 C3 E! N ; Split on newline (`n)
, v: G. Z" t# a, ` StringSplit, word_array, full_path, `n
) H2 ` j: G0 a, M ; Take the first element from the array
3 L0 W. R# D: }9 ^ full_path = %word_array1% r# T8 G& P4 \$ |) q: J
; strip to bare address
$ Y+ K2 P3 h- e; b2 }7 S% S3 B9 T6 W! M full_path := RegExReplace(full_path, “地址: “, “”): ~8 |$ ]; j/ R$ a8 C8 ?
; Just in case – remove all carriage returns (`r)% u& X' a+ r' h
StringReplace, full_path, full_path, `r, , all# f& U2 E; Q% c
IfInString full_path, \( B/ G. L+ j6 W& X, ]
{
; B Y' q m$ E, \0 [, [ Run, cmd /K cd /D “%full_path%”
8 ?4 k2 D2 a7 S6 L6 J( E8 H& O }
' \7 B9 U% w% a; \6 |( O- z3 O else
& n; D8 L' U" w {. ]: A7 b9 W* ~7 ]0 {5 T3 ] w
Run, cmd /K cd /D “C:\ ”
* m$ @9 c+ I( T }5 ~7 b% f% q# p2 w) _
}0 I& u7 }( ]4 B( _- u/ W# ^
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" I8 f2 F! A: O( g+ r* [( J4 W$ c
这段小代码肯能有两个你需要修改的地方4 L7 ?0 v# n) g2 C
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ N' m1 D( S5 N* J
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! v8 k. v8 s, |8 r9 I; w" T
|