此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' B. a! x7 l$ t. I E% ]2 x 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
) N: z. s* F9 I9 m- h 方式一:
2 f/ ^. g% |$ x2 I! ~7 e- S 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ F: K$ f& d& o, o- H3 I; R
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和% P3 ^6 c1 D3 Y5 |, j+ g
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- T4 G/ G/ G0 X w+ T. Q9 t1 a
方式二:2 p0 M5 |& C9 S- H" x* c) c
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: p! b) T+ G4 G* D8 {. j* E' [* N
SetTitleMatchMode RegEx+ ?0 N5 A! w1 e/ \
return2 Q6 I2 ], R+ r7 Q* |
; Stuff to do when Windows Explorer is open
. S, z7 f. v6 b f" ?' V! Y- F ;
5 F# G6 h9 G4 t, U$ ~* l #IfWinActive ahk_class ExploreWClass|CabinetWClass+ J, O- ?5 V8 D$ u. C! F
; open ‘cmd’ in the current directory
, n* G) Z8 ^3 ^- `# B+ }+ v ;
8 a( m5 v4 a7 c2 W4 n* p. Z8 o #c::. A* a2 g$ ?5 z- X5 Z* z% {4 z% G
OpenCmdInCurrent()
" r5 E8 \* G$ e+ [ return: a% Z# ?6 C1 S2 k; |( f C" S- U
#IfWinActive( b- O: _; c% Z) O6 b
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 d) } n! D+ x1 k ; Note: expecting to be run when the active window is Explorer.& K' o( ]. W/ F m9 O) q
;6 y. j- q9 Q/ R4 V* ~1 J* v. @+ q
OpenCmdInCurrent()7 l. X! T) r$ {2 Y" q9 r
{
* h r2 G& l& n! Q ; This is required to get the full path of the file from the address bar
* u3 i( A& s: @+ H L) o: l: A WinGetText, full_path, A( n, _! V' A7 ]8 X
; Split on newline (`n)+ Q4 g0 L @0 h2 i
StringSplit, word_array, full_path, `n$ `! r1 o& D* D4 o0 Q8 G7 H3 U: f
; Take the first element from the array
) a6 k, }# `4 g# ? full_path = %word_array1%/ c3 X% b& [. x3 J4 W! t
; strip to bare address, v2 l6 p* G- }$ s! O# Z
full_path := RegExReplace(full_path, “地址: “, “”)
: F* `8 V5 v) e g1 O# B8 h ; Just in case – remove all carriage returns (`r)0 Y, o& S3 ^$ E
StringReplace, full_path, full_path, `r, , all
' y( `$ J4 g: ?$ s1 t IfInString full_path, \6 C3 {7 k0 Z/ D1 ^& w& x1 Q2 U! T
{
% Q: `3 g1 B( ?, s6 Q. F( C: Y Run, cmd /K cd /D “%full_path%”
6 y( u$ B( ^" z }0 \2 ]% R1 _$ B' K3 D
else6 W5 w9 \: a! ?
{ _! Y! f# R( P6 K' g, z& G
Run, cmd /K cd /D “C:\ ”
1 b h' z: h9 \ }# n4 `; f/ J. t2 T" z% s6 _$ v' Q' y
}
5 S, W+ S% |9 i' | 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: k3 D: _1 J7 b4 g 这段小代码肯能有两个你需要修改的地方" Z9 e2 n U& }3 o, |0 `6 L% J
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键* X; G2 R) e0 x- q7 y, V; y' n
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. z1 }4 z! W; U1 [) N |