此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' t; y$ g W! E. u
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。$ ~' ]' z8 E H3 K" L- V
方式一:
1 O6 s4 B1 _. c) V6 C5 f3 z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,4 {' x3 G- k1 @& \7 Z- ~
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ {3 s6 u& ?+ p8 X! Z! q& G HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" _3 ~' q5 L% s& D3 `, f8 u6 M
方式二:5 t' ^5 u- D1 M( ]5 X1 s5 `: U
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
3 E4 T n3 u3 B- x& x1 X SetTitleMatchMode RegEx
$ q7 V# l Q1 W( S) |0 q2 ^ return$ k8 \/ Z9 N$ D4 U
; Stuff to do when Windows Explorer is open# E% l9 [' l. b7 b( |# `, f# E* s
;
# d& h+ [) P/ O u" R; c #IfWinActive ahk_class ExploreWClass|CabinetWClass
7 r" M- ~9 u) W% _8 Z ; open ‘cmd’ in the current directory
$ w; d! _1 O& j ;( `+ J8 B! _! G( W' ~" E2 E2 V" G8 k
#c::
[' }/ Y) q* }% `3 s OpenCmdInCurrent(). G' G5 m* z7 k& K6 ~2 O& m8 e! u# W! o
return5 _' [" n! k C4 G# s b+ u, r! }
#IfWinActive) _( z( j0 k4 d6 g. C% U0 Y9 H) S
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 p$ I- G1 W$ f/ q
; Note: expecting to be run when the active window is Explorer.7 i* {7 ?2 X1 [$ ^# j
;3 h2 Q* C. M* E! P" r$ C
OpenCmdInCurrent()4 h: O' B3 f' ]4 _/ i# t
{6 c: w+ O4 M1 \2 C% e! c
; This is required to get the full path of the file from the address bar
4 X. \* n, Y/ C4 s# K WinGetText, full_path, A
( O X* y9 S5 D" ]: f ; Split on newline (`n)
6 E1 a! j# ]7 o5 W2 _7 d0 H StringSplit, word_array, full_path, `n
5 E6 E& ~7 W# _1 ~ ; Take the first element from the array' g7 z. y& j1 f6 q P# e7 M
full_path = %word_array1%$ p0 V# P: J5 l7 T7 P* O
; strip to bare address3 ~! D, G0 h2 i# d& M4 r
full_path := RegExReplace(full_path, “地址: “, “”)5 m' X, x) ^: Z; `) T
; Just in case – remove all carriage returns (`r)$ W) i# I6 v. v0 s% P
StringReplace, full_path, full_path, `r, , all
2 K7 Y' y( z1 n) }1 Z IfInString full_path, \
. p+ n$ G4 d+ `) D2 H( V; H* D' S {
4 ^/ T! @( Q3 D( u Run, cmd /K cd /D “%full_path%”
- I8 i& {; V% K- Q) Z! k }
& f, d* R- R) J9 D4 F& M else
0 z/ f; e! ?" e. m {# G3 G/ u: s9 t9 E, i7 j: \) f! d
Run, cmd /K cd /D “C:\ ”5 s1 Y. f) |0 s
}
5 G( C% S; b7 [+ u p9 } }
( h/ T. y# s& f: K0 I 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' u C+ N7 p5 }" R# U9 l1 b! {
这段小代码肯能有两个你需要修改的地方
( H; e; E1 j- A6 e4 n! I 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( ?7 |( k2 E8 i2 \ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
1 ^% w# T0 V; X B2 B |