此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 l, L- f. q- H% p7 o, m1 a
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, I6 E$ W: M( |$ {5 D3 r( ` 方式一:: v! o7 |0 w W# ^4 Q. N, r/ H$ j
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- N+ l+ }5 m# b2 N 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
$ M, c& H! s* f. n: ] HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
$ t$ l f: ^) P. L; C8 o; n 方式二:$ i! d/ D3 _5 E4 _2 G: k
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
1 H% V6 D8 {! g$ ~2 @! `/ f SetTitleMatchMode RegEx
; w+ |$ B; W# N9 ~1 }/ {$ a" ?+ B return% Q8 ?- o* u; T8 I/ b
; Stuff to do when Windows Explorer is open
$ l2 [8 k+ z; x& n+ W ;0 {) \1 i u& {' ^5 B
#IfWinActive ahk_class ExploreWClass|CabinetWClass; v0 c6 i# c; @& [8 V4 j
; open ‘cmd’ in the current directory
% i- _3 p* S: u3 v' R ;
, Q) d; v% D' c3 p% o #c::: l/ F J" Q" [# G" e3 Z1 i; {2 m
OpenCmdInCurrent()
) @1 D2 W/ l! l5 e# g0 s- u6 p4 q return
9 g/ I; Y# o1 D( r% r #IfWinActive' ^/ b& b* t; c7 _% Y1 d6 i
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
5 u7 m0 _- R6 q+ C/ j) A ; Note: expecting to be run when the active window is Explorer.
8 G5 a0 D: O: [6 ]7 a5 d ;* K, U3 T! R+ ~( G
OpenCmdInCurrent()" J6 t* j* `! U% ^3 Z# `* t5 T
{
x4 V2 f8 S/ y2 Q4 }& {; U ; This is required to get the full path of the file from the address bar
( u0 S/ x+ M' N2 U' ^" M WinGetText, full_path, A
) G% N- p! B! ~: ?7 b% _1 i ; Split on newline (`n)
" o3 h2 F5 I0 W- b: e$ G+ i8 U: k StringSplit, word_array, full_path, `n
/ L& S" H3 z2 O( W% Z ; Take the first element from the array* ]. z) Z- Z4 x8 j! ]
full_path = %word_array1%% w5 R* N1 C# g2 n
; strip to bare address7 Z" I' Q( _8 w8 g5 F6 k
full_path := RegExReplace(full_path, “地址: “, “”)
& c0 V" B! b, Q. f( z ; Just in case – remove all carriage returns (`r)' ]0 b. P' X2 Y) K" V
StringReplace, full_path, full_path, `r, , all2 H# g' b, i2 g* c" J6 Z! X, u
IfInString full_path, \
; C" B6 Y& r7 { {
" V+ f" r) E7 a5 g8 N Run, cmd /K cd /D “%full_path%”# N0 t b6 R# c# a( W, I* ^
}1 i- ^9 `4 }; H0 o9 z& Z2 m
else
1 ?, S m3 `/ o8 c {( @, z0 [( L; F5 g
Run, cmd /K cd /D “C:\ ”3 @# {3 J$ ^" A: B" z5 `
}) r+ y# `/ f; r: O% L
}
" i, ^ P) O* [5 J: [ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。9 s% W- ?0 I y6 q
这段小代码肯能有两个你需要修改的地方 n7 f7 Z+ x& H1 O* ?$ L( t
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键+ x7 i W1 N" T! Z# ?, ^4 G2 ~
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; m% D* i1 }* P/ E9 |3 N |