此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 Y6 Q/ V& P7 B+ ]: e 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 t3 D( w/ p/ Y
方式一:
4 w; ~. F9 S* W 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
+ b& y; Q5 U4 U& |) q4 z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 u$ Y- [; J6 v1 L& j }# D* b
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! U: c2 r: a4 M( J" D 方式二:8 J. P1 @) F, c
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:* d% e, l% l; { v A
SetTitleMatchMode RegEx* N9 B. H1 A! C
return
3 x6 p4 R. I5 i ; Stuff to do when Windows Explorer is open4 L/ M' u0 F- o5 R; {6 Y
;
0 L& P/ O1 ?, X y #IfWinActive ahk_class ExploreWClass|CabinetWClass' K0 d" h% K1 Y# s( ?- N2 q. q3 z
; open ‘cmd’ in the current directory( l* r+ h8 s/ p2 C- f+ c) q
;
2 H( u( i( s/ I% z$ E #c::) ~8 P3 v6 O6 m* r; m' i# W
OpenCmdInCurrent()
) d; d0 _7 H4 l1 ` return
; L; ~2 e4 T, {+ {( ^ #IfWinActive" z B) ?/ y" T; r" }& d9 x
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
$ I! z; L$ v4 b8 H. ]0 R ; Note: expecting to be run when the active window is Explorer.
" w. d2 H& j* }' Y1 r. B ;
6 Y& h8 R2 C; O* [* f6 t OpenCmdInCurrent()5 p% e O* i# n8 n1 n
{5 P2 E: {$ y" U% {8 S4 u( a
; This is required to get the full path of the file from the address bar
, V/ Z5 _' L6 p9 g5 N i WinGetText, full_path, A# H7 t5 n' ^8 _5 y6 Y- C
; Split on newline (`n)
% r9 r( ^" D+ t. N7 v. u% W StringSplit, word_array, full_path, `n
* D1 j! z1 I. Z4 Q ; Take the first element from the array8 c& }1 i/ M0 F( |$ n% Y
full_path = %word_array1%
7 D' Z) q9 O- }5 h) u p ; strip to bare address
9 i. k4 |: V/ R4 b% u full_path := RegExReplace(full_path, “地址: “, “”)
; j' z" {1 |- f0 ] ; Just in case – remove all carriage returns (`r)
I( Y6 E3 N+ E! @# q" o* q StringReplace, full_path, full_path, `r, , all
. \) l5 p$ d9 H( j IfInString full_path, \# \& z8 o7 M$ i& r7 |" o) O
{0 T {( t& g* z' _
Run, cmd /K cd /D “%full_path%”5 I; I" U" f& \/ r1 [6 p) ~" u
}6 A! D( v9 d1 L' C" ?2 A5 X
else& `1 V6 x: S g8 B) V
{
6 z7 S9 j) j2 Y2 z) }2 ^1 Q( g Run, cmd /K cd /D “C:\ ”
4 ]# \+ y% H/ Q& v2 M0 y% {# W }
: G: q' u7 `, \, u2 H2 O# g }
3 Z' B2 f3 I) s" c! F* m" f5 w% S$ s3 l 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 S# L$ V- y- T/ G. X 这段小代码肯能有两个你需要修改的地方) S1 o9 W& L7 U. S# [( b
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键, U+ B' f% l( V
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “3 j8 d0 }7 M+ t8 D+ |% w5 k$ _
|