此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 h& Q# j- X7 P% n
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 O6 [: ^7 ~! o2 v 方式一:
1 N' ?& |, H2 Q! f( }3 U5 P 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,% ]9 n7 L8 U5 J- D# s. W$ f
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 {! } N4 e$ V/ T
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ k& z. J8 p% Q. H: B8 \ 方式二:
) l8 x: r/ V) W! H, i4 o 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 e' ~9 }# U) K, I, _& o
SetTitleMatchMode RegEx4 [- `/ W( | z) f( F
return
* ~, k/ R1 l5 Q ; Stuff to do when Windows Explorer is open8 `* e1 {1 c! h. h; A& D4 F4 |, F& E% h) L0 b
;
y2 f* r+ i, E) `+ P! N #IfWinActive ahk_class ExploreWClass|CabinetWClass
' c* ~% q- Q* V0 X `- e% e+ s5 c ; open ‘cmd’ in the current directory5 t& R! s6 |) ~. @: W: W
;2 X3 v! @* K3 Y9 C
#c::
3 q4 O+ ]9 N2 P6 _( Q* x _4 Y OpenCmdInCurrent()
5 C1 n. h: Q t. k. A6 [ return
9 k! P% k: c# A& H5 V& o #IfWinActive( c4 }# |$ H6 }% r
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( S! `, t- f( _+ C( @9 f2 R. x
; Note: expecting to be run when the active window is Explorer.
; \3 b( e7 ~- K* I ;) q( ?* K! t6 n- H { H* v
OpenCmdInCurrent()
. t& y/ ~- P/ C8 s0 I% T% @ {
2 |, V; R q8 `7 R8 l; u% C0 ^ ; This is required to get the full path of the file from the address bar
( Z: i: X+ I8 u2 A WinGetText, full_path, A' J3 k" ~ p7 S- `; F. X
; Split on newline (`n)
5 r! i3 V1 M8 W# t2 b/ ~ StringSplit, word_array, full_path, `n+ h/ z( B/ p6 g' f6 w
; Take the first element from the array
7 L7 ~3 O7 s. G6 B0 {1 Z1 m full_path = %word_array1%
6 ^8 U7 W6 E3 R- C* V ; strip to bare address" i9 n1 Y) \" j2 v. E, B' W
full_path := RegExReplace(full_path, “地址: “, “”)2 g! e! [$ E% [* h2 U; ^6 R3 [7 I
; Just in case – remove all carriage returns (`r)
7 W/ i4 s f# H Z, B& v! h StringReplace, full_path, full_path, `r, , all
! t2 H0 S& e) e; _* H IfInString full_path, \6 a; \! O* J; b3 Z* Z2 d
{* x9 [" i9 w; [- M- R/ p% e
Run, cmd /K cd /D “%full_path%”: R n* W! T6 ~ }; N2 n
}
- N( C Q k( J2 V, ^% b4 L else$ ~7 ]* P; ^ Y
{
- w% q- f, C) r Run, cmd /K cd /D “C:\ ”
P+ Z3 f: C2 I. u$ z }
" C2 B1 J) E3 ]: d }; `" g' @2 W3 g9 H
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 u: {; I! O; H3 h- O 这段小代码肯能有两个你需要修改的地方, G: U: Z$ |4 V+ Y0 d
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键. F0 f& m `8 h4 S& C7 m
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
( C4 g% z5 x5 e6 V1 j |