此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。" V& h: _. W5 x1 @
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
) c+ Q) j5 d1 S$ q1 F 方式一:5 p# I- [- w) f; L* F: o% N/ {
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
' S0 T' d- ~- y7 i, N8 x, s: V+ y! ? 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
& V2 w9 |* A2 S' R# x HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
v5 j! ?1 g3 e) d! ]6 l 方式二:8 i% B9 z- A+ }% s: B8 h6 L
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( Q& K; K9 F( D$ f5 T( ?/ K
SetTitleMatchMode RegEx2 I3 @) h' w- B6 R3 v$ ^4 k
return8 o% [* E- R+ k! m& [& ]' t \
; Stuff to do when Windows Explorer is open
, j$ A/ S6 b- j4 J ;( ^4 C8 y# L7 G
#IfWinActive ahk_class ExploreWClass|CabinetWClass
2 _+ u. M$ A2 B ; open ‘cmd’ in the current directory* ]" @* {, L3 _2 f2 f2 W
;/ Q* W2 `: ^+ u" l1 c# L% k
#c::
/ F: u/ J- X5 @ OpenCmdInCurrent()
$ R8 r9 ?% p- k) m5 h O" e5 \3 y. D, \ return
; m6 K" ]! n$ z. N9 ^' _9 H! K #IfWinActive
+ H+ }) |; f. |& O6 U9 a& ^" I: ~ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. D1 q4 H$ G1 u+ [8 D9 ? ; Note: expecting to be run when the active window is Explorer. |# N' y1 A0 J" J j
;7 T" ?" Y. f8 w* [7 z- O
OpenCmdInCurrent(); U1 c+ B) ]; H! y0 s- w; r
{
4 K; B. b! `* x* j6 Q* i+ { ; This is required to get the full path of the file from the address bar, F# ~1 X- d1 ^3 y6 A/ X& `/ ?
WinGetText, full_path, A [0 Z( U1 y$ w
; Split on newline (`n)3 b d* k) ?! R8 O# t3 k
StringSplit, word_array, full_path, `n
* Z# [, s. V% Q( { P8 ] ; Take the first element from the array; a+ o: \/ h3 a# r
full_path = %word_array1%6 [9 _2 @- ~. q3 Q
; strip to bare address
* z! t3 e# g F% |8 o' s full_path := RegExReplace(full_path, “地址: “, “”)
* T$ n/ U' l( j- [' N! j. G ; Just in case – remove all carriage returns (`r)
5 P+ b3 @& n- m StringReplace, full_path, full_path, `r, , all
2 U; D, i2 K: b; l8 U# y IfInString full_path, \3 _! Q. D8 w( G4 J+ _3 d
{
* E$ W5 m$ ~. N z; ] Run, cmd /K cd /D “%full_path%”) u1 Y/ H" {/ X
}* b- o. o& M% w: n
else, j* T: i: d$ s
{8 B- M6 O( s5 [. [
Run, cmd /K cd /D “C:\ ”0 v! p4 j" {) V$ `5 L+ g
}
' ?7 b5 @: C9 ? }6 W% n" x; ?' `' o( U. ^# h. I; ^
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。; l' G+ ]+ J) S( Y* S" D" o0 t
这段小代码肯能有两个你需要修改的地方
( N2 } F% l' `- d 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" u8 q% k- |; S3 |6 V8 d 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! N2 y @$ P9 @$ G
|