此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ r2 b8 J. z2 O9 Z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ p9 z) m$ q* B/ B2 \/ E 方式一:/ k' r0 j# y; Z t. j
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
8 E, r* r9 a J, ^/ K$ U6 Q 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ U' H# Q S# E9 J
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。* x/ R9 f; l9 T
方式二:
+ ~" c4 S* m# o# r/ X 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:$ Y( ~/ ~8 `8 W" c0 l7 `! s7 E
SetTitleMatchMode RegEx
+ k1 S! ~3 t5 Q3 }7 J return3 z* ~/ \5 y% s* \; t% X
; Stuff to do when Windows Explorer is open
3 [$ q4 | {' s8 {2 t ;4 x0 n, I. u2 F$ H$ X# T i
#IfWinActive ahk_class ExploreWClass|CabinetWClass
6 g: f: ~. y; P0 G8 ? ; open ‘cmd’ in the current directory
9 h/ e% L0 \! O% ? ;
) Y; f( k, i8 K9 Y4 v" X/ D0 b7 I9 C #c::. L! Z+ ~0 G+ M5 i
OpenCmdInCurrent()
& |% |% W; W" v. [4 B( l return
% }) u5 Q; N/ }' V4 C( u( h( x #IfWinActive+ W' u# |+ R' i. \2 d
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.% {' K2 N0 u* D/ V/ {
; Note: expecting to be run when the active window is Explorer.7 d; L O" i$ d1 P
;5 f: f1 G) k2 ?
OpenCmdInCurrent()
; u" g; \2 E4 _; |' l+ n {3 u4 G( E- w9 d8 ^3 j3 O
; This is required to get the full path of the file from the address bar4 R3 E* \8 K3 Z0 V
WinGetText, full_path, A
N7 A! _2 C& _0 c ; Split on newline (`n)
. s1 h/ ?7 v* N# b* T StringSplit, word_array, full_path, `n
) B& O, x3 Y. ~+ ~5 R! X* S0 ] ; Take the first element from the array& |% L6 Z; Z) N, f4 e
full_path = %word_array1%+ s) t3 M0 v% u: s7 y% ~
; strip to bare address) q/ O1 w! R( a- d8 |! Q: I% r
full_path := RegExReplace(full_path, “地址: “, “”)
8 p( v# O- ?; c( V, ]) h% n0 { ; Just in case – remove all carriage returns (`r)
' i" y s2 V7 v$ R5 b StringReplace, full_path, full_path, `r, , all' |- r. a5 t" q* \5 {
IfInString full_path, \1 Q: H1 U& I! r# h, F( S5 n
{
' ^) S4 b; N- o$ b: N+ `% i Run, cmd /K cd /D “%full_path%”. X" w! d- _! ^) J- u/ g6 N" f
}3 P7 ?4 i1 z0 q1 i( s
else
+ t2 d! Q2 h! s& J' D$ E. O {: w5 b% b$ f* T3 d, T2 ?3 L
Run, cmd /K cd /D “C:\ ”/ B$ K' v4 q, R- a% w2 Y( W/ s
}
3 U; K$ X+ t) t9 q! k3 u6 q) I5 M }
* i# t) F6 Y' p0 r! L 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( H. A9 Y# A, W+ j& m 这段小代码肯能有两个你需要修改的地方' M: u l: Y6 {$ w
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键% R& q5 r# j* Q1 A$ x/ W7 B
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; P6 b: {0 [4 Y' p J |