此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( A2 a8 j7 c5 c$ K4 \
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。$ j! c* R# Z* J9 K# S0 D% N% \
方式一:" m/ m5 T* Q* P" J) d/ p' ]
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
* G( B n! F/ |# | 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 S! f4 V2 K) l$ [6 v
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 u0 C6 i. m" J4 k7 `. a- @! h
方式二:
# K7 C0 ^1 y3 `" V3 m8 j 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
4 q' T' S A; ], |+ i/ x0 s SetTitleMatchMode RegEx F6 Q- H5 j. O: p
return2 p: n6 h: c! f
; Stuff to do when Windows Explorer is open
T; |0 |" B" q2 [: l ;# n' y- k: d5 f: U ?7 F) E) t
#IfWinActive ahk_class ExploreWClass|CabinetWClass6 w) d; O# h1 F
; open ‘cmd’ in the current directory
* Q+ C5 i5 i# `" O; H ;. F& M9 z0 s" s1 Y% z/ k$ h: n
#c::0 K1 I$ T. ^, Z$ R- ]/ Y
OpenCmdInCurrent()
/ L) F8 W4 _; J0 a return, _2 V; S9 b' W# c- \
#IfWinActive J; |0 u6 f; X# W
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( h ?) G* I8 M5 W! n ; Note: expecting to be run when the active window is Explorer.
: C/ w W) Q1 `. h! Z: o1 _5 v ;
( P2 k- v, e8 g' G6 F! e, w/ v OpenCmdInCurrent()
! E/ B/ s7 T- g9 b& k. ^* g( A {. J+ p$ Y. y1 ~7 K1 G ]& n
; This is required to get the full path of the file from the address bar
; W$ j5 a7 M2 O( o2 l WinGetText, full_path, A$ g+ ?5 y8 S( E7 `4 H6 U* Z- C
; Split on newline (`n)/ P: q1 ]# o5 Z1 H/ j7 e- @6 b
StringSplit, word_array, full_path, `n
: J$ v/ p! \' ?- x7 z ; Take the first element from the array' R# E9 k1 u1 s/ Z% [
full_path = %word_array1% \/ Y" J& c! l9 \' ?- |3 C
; strip to bare address
- X3 F& f+ Y7 n( ~: ^ full_path := RegExReplace(full_path, “地址: “, “”)
+ W, |( ~8 @$ }9 O7 x/ o2 r ; Just in case – remove all carriage returns (`r)
: h5 Q" j4 U% P& F StringReplace, full_path, full_path, `r, , all
% i" @) x, D! c+ t' Z" ]9 r J4 Y IfInString full_path, \" @4 [% ~ P% j7 Z5 e
{
5 K+ s( G) S4 P5 Z; H# A& t$ @- ] e Run, cmd /K cd /D “%full_path%”' W/ Y. x! p% K$ ` W+ T$ c' e
}
' z, h- I1 K( x, Q8 s+ x5 g else7 n2 \ g5 \+ D2 h/ s
{
3 F- U5 M8 N" a; }7 m Run, cmd /K cd /D “C:\ ”6 V$ f [+ u2 P; ?4 G
}
4 B( R8 d3 x* j/ n" H" g" s& C }
0 w, F) D8 I5 S1 \& W9 d 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
4 Z( i9 V/ C+ `' B) x 这段小代码肯能有两个你需要修改的地方7 Y" e) n$ B6 y. O
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键. y6 r' U: x k
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 b' |! {" E# l
|