此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' @" \; [$ C6 e
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 s% R2 `$ j0 T' |- E; d
方式一:9 [1 y2 ], E- U1 G2 `, W
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* x' d/ R$ z$ t5 d3 V- }% r5 v
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: B5 a* B$ S9 f* C
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 P9 N& B9 J- Y) w 方式二:5 R# _2 b) `+ Y- N& S% c9 J4 [, K0 D6 a
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. W3 u. H/ k( h6 g0 h& T7 N
SetTitleMatchMode RegEx
# f$ i+ b! J2 e5 V% k return
& ~) X/ y# o' [5 O( ]- j* d* {9 z* J ; Stuff to do when Windows Explorer is open
! c' J. @2 P- c# N& l ;: j, u3 [' h- {8 {
#IfWinActive ahk_class ExploreWClass|CabinetWClass
! G7 ^! l: Y3 U$ M ; open ‘cmd’ in the current directory5 [4 T* ^# j5 F6 j1 {3 r
;: }: T2 @+ M! y0 \
#c::8 {9 y1 \9 X4 r; |3 P
OpenCmdInCurrent()/ N* ?' ^" o7 `9 Y5 |
return
8 t, @6 }: S- r4 Z; Q0 B #IfWinActive
% V& r( U- l E' r; N+ c4 ? ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
6 j7 g2 ?2 I; _9 I0 d' N! O) n+ s d; @ ; Note: expecting to be run when the active window is Explorer.
$ q4 Z& e1 Q3 i# _ ;$ ~! |0 s; H+ X E9 z$ M
OpenCmdInCurrent()
% A' f! @+ ]# s* w+ V7 n {" _4 z7 o3 i1 h1 R2 e" u: C
; This is required to get the full path of the file from the address bar% N* P3 w! i) D; T6 g- D- v
WinGetText, full_path, A* b# V% u. y7 ?4 E7 g
; Split on newline (`n)& ~( Z+ \/ T" D4 w9 m% o* j3 Z, R
StringSplit, word_array, full_path, `n
\- K) O) p5 n4 l1 M3 q/ q A ; Take the first element from the array5 H, f3 }/ C! R( z8 T
full_path = %word_array1%/ @( l4 ~" T3 m; K8 K" f
; strip to bare address
( r5 K/ Z o7 ~4 S( \7 g full_path := RegExReplace(full_path, “地址: “, “”)
" B5 K, h! b3 I% k% ~$ Y ; Just in case – remove all carriage returns (`r)
( M- B% m- c0 i( A' n- C StringReplace, full_path, full_path, `r, , all
3 `: z' u; @7 ~. V: _ IfInString full_path, \
) H5 l* M- P, C/ ]& d/ w; P4 ? {; ] f7 R p+ g3 I
Run, cmd /K cd /D “%full_path%”
4 H, b# g- r, o4 h3 g# q }: y5 @& c h7 d. i
else( ^2 a1 s6 h* @& Q0 f+ ?, c
{
& k" [. b& q. `* I' l Run, cmd /K cd /D “C:\ ”7 u' G+ ] {/ X# t( p
}/ M' z+ l- O& q8 F/ f! r0 x
}; m1 b! y4 M& p, |3 ?% s
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 Q* }0 }0 X* x0 |" S% A B2 P6 G
这段小代码肯能有两个你需要修改的地方
/ ~4 l5 e$ I+ H 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
* K- j" D" G' _8 f- Z 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ m8 Z8 O Q4 D+ k/ c+ I
|