此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' Q9 _8 p4 a) S. m
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 x {2 G0 Y# a3 g 方式一:
J+ r+ [' e2 `+ J! K9 t* W, g 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表," k! m: Z# Q4 J. i2 T9 k5 ^& V$ g
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 ?$ u3 C- m, Z5 Z( z1 p
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* t- i- o- c3 y+ } 方式二:( A" O( o9 C3 _3 t1 S% T9 t, b
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:8 Q3 y; m6 m$ u
SetTitleMatchMode RegEx* ~8 q! o! s! C8 ?/ o
return
! r* i T' c4 o3 ^9 y ; Stuff to do when Windows Explorer is open
, E: d3 p4 s5 V! _- Z9 j9 j$ Z ;
4 A( `$ \* } _7 { #IfWinActive ahk_class ExploreWClass|CabinetWClass# T' t, b2 i9 u
; open ‘cmd’ in the current directory
* ~7 Z% m3 H, U [4 L0 l3 { ;$ ~- I }6 \: v( d
#c::$ y f! H% U7 W3 W
OpenCmdInCurrent()
. K0 E, v9 ^$ U1 r/ W* j. T d return
2 C2 E. W6 D" q8 z4 Z" U9 h# f #IfWinActive/ Q# j3 ]" |' E. i! [
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 J( J# z6 ^- O9 c8 |) e" @ ; Note: expecting to be run when the active window is Explorer.0 E" H. i8 |6 }1 \
;3 t' J' h6 u7 x' Z8 b* T
OpenCmdInCurrent()
! N2 g* ?7 a1 w! c2 E( _ {
1 h3 V; k2 Q/ i* a( j ; This is required to get the full path of the file from the address bar5 a3 C7 B# e# y, y: x
WinGetText, full_path, A
& P& X! A0 t0 i ; Split on newline (`n): `1 ]# W$ `0 I8 [9 @: `( s- ~
StringSplit, word_array, full_path, `n) N% O. _4 Y s7 k- {. o( h+ M4 x
; Take the first element from the array" }$ v! f7 p1 C) O. G6 Q
full_path = %word_array1%# Y7 ?% T7 b' a! o% t% z
; strip to bare address
5 B! ~6 _: l4 ^; ] full_path := RegExReplace(full_path, “地址: “, “”)- p. D5 \- R2 Y5 h7 E6 m
; Just in case – remove all carriage returns (`r)/ j; M( r0 v+ g; N5 l
StringReplace, full_path, full_path, `r, , all
; d: v2 s" S# l6 d# l- N+ M IfInString full_path, \8 U: g' T" o3 ]) S2 F0 h
{+ p( L; p; P. L) ]! P
Run, cmd /K cd /D “%full_path%”
. K: K' ~) b" ]. @. U# b& h: l; e& I }, |8 A4 {! n5 h' G8 U& b, {5 i4 n
else
/ }) |3 T- D- D- b7 Q% a {
& Q+ b- `" G' N2 a5 I3 Y4 M; { Run, cmd /K cd /D “C:\ ”, [1 w: e. y- b3 U7 j
}
1 l. s& @- @, q }
* \# Y% }4 l. M/ Y7 L% X 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ U( @/ e Y4 d6 I' | 这段小代码肯能有两个你需要修改的地方
, E- {. d; C7 u6 o# b$ A8 ~ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" I, Y! P3 B* C* b& o9 E 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 n$ ]4 X" H7 t0 {) f: V, t, D) V
|