此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。" ~6 h+ Q5 D% u( N8 H" a
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 x; e+ r# [, e+ L$ d
方式一:7 v( p8 n0 Q* f( K6 u
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, E& j# R+ b) \' c- M6 y( v
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
( y: X$ |% B4 z3 D( H j HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, [) N$ K, F. U% [% ^ F
方式二:
1 Q0 F& s' Y# G! a7 J# y2 c5 ? 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
0 }6 S7 J- j5 C1 j: P' l SetTitleMatchMode RegEx
7 x g, j2 }) R0 Z return3 ~1 l& H) i# r6 Q L* ]5 m/ g
; Stuff to do when Windows Explorer is open
4 U& c7 U% }& O4 R+ y ;
( T4 F- c, v* g; Y, t #IfWinActive ahk_class ExploreWClass|CabinetWClass* |" O4 t7 ?) V0 h7 k/ R% C" C
; open ‘cmd’ in the current directory
5 n9 d* b) w) n( ~/ P, o& i ;; F% {" k3 }7 {2 {
#c::8 R8 B8 W2 p8 {
OpenCmdInCurrent()
& n; l2 H& _( ?; J1 I) Z5 I& h; l return+ Z/ A( W* o5 R/ H2 P
#IfWinActive0 i# ]/ g( M& o, I
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. B* v& Y, ]4 y I ; Note: expecting to be run when the active window is Explorer.$ k" u' N$ F5 L* ?1 G
;& X5 ]. W4 r/ z. Y0 ^4 O' v/ l( ]: u
OpenCmdInCurrent(): K2 m U# l6 }- c# N
{
9 X( A2 M& j' ~! | ; This is required to get the full path of the file from the address bar5 c$ J; T: ?) W" A* e$ ]
WinGetText, full_path, A
' ]+ {. R5 s+ w7 L9 f2 o ; Split on newline (`n)8 D+ S4 Y6 l! T d' x. q
StringSplit, word_array, full_path, `n! G% l0 F! h* p" j
; Take the first element from the array, i! F% O, r2 f P: z. z: o$ O
full_path = %word_array1%5 ` f2 d0 W- `# n: Y6 z5 v- p
; strip to bare address
: g1 _* R1 t3 d full_path := RegExReplace(full_path, “地址: “, “”)
( l( r5 E3 r6 Y u& Y ; Just in case – remove all carriage returns (`r)
6 x8 b! A2 o4 |$ n9 V- t' ] h) n StringReplace, full_path, full_path, `r, , all
# \; b. K. h. B/ }* J- ` IfInString full_path, \
9 o6 |3 ]9 s" { {2 b# W* s& ]$ G7 T2 {( ^
Run, cmd /K cd /D “%full_path%”6 a3 F, N" Z8 M* M0 b. L$ v
}
* n) w, Y( n7 v4 n! L' X! L r else2 K( e% U) X3 { ^ D. O8 A# | S7 h
{" L; P4 b' F7 \$ L# R- Z
Run, cmd /K cd /D “C:\ ”; Y8 _& q6 E3 t5 ?
}
$ z. {) U( k" p }8 P) {5 [8 p7 _7 m4 m g1 Y
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。# L1 p4 i% {) q9 |- F! U y. K
这段小代码肯能有两个你需要修改的地方
2 l$ T% ~) D! H 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键! Q! q- K, w4 l: g/ [5 L& \' w0 n
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ B3 @1 ^8 r# c7 q* s4 j9 Z |