此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
$ v0 \* J% i8 [0 \- h 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 a+ e: L$ G: z/ Z' N 方式一:4 ^( l( C _' x- M" X. X- ^
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, ? P: f+ R* t3 A' H) U8 P
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 a; V& q1 s+ H7 | HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
. l$ H8 q9 A1 H! s: V. [1 r 方式二:
- m! M: c" C! e9 x. @( Z2 J1 t 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 L& g: j4 V% Y+ _
SetTitleMatchMode RegEx
! L4 J" M7 N! G3 |) C return
2 C3 Y& P# t) L! L ; Stuff to do when Windows Explorer is open$ W+ E- u1 J$ [! ~
;
- ?2 W+ {3 z; x& H #IfWinActive ahk_class ExploreWClass|CabinetWClass
o( v% ?; b; F& W8 b ; open ‘cmd’ in the current directory
* T' _& h7 c- x$ S/ V9 [; Z- E( I ;/ V4 V+ Y1 N% _$ Q2 }2 Y
#c::
: ~' g8 |% B* l* V7 S) j2 G OpenCmdInCurrent()
# ]' ?0 H+ Z7 g# N- @3 C return
n1 H6 d7 w% B" }: \ #IfWinActive
* x6 C3 C Q' G5 ?( [8 b8 w ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: n; c9 E: t* J8 {1 A; K! O9 M
; Note: expecting to be run when the active window is Explorer.
+ }. K7 I! t2 |* `" `4 d3 \% p* H* O$ h ;
0 Z0 A' `, _- ?* Y; }0 Q OpenCmdInCurrent()
. J1 y; z" t h3 X: y" A {8 v' _% R7 w0 E* y9 d
; This is required to get the full path of the file from the address bar0 K1 H+ ^' O% [6 S: v: e5 v4 M# E
WinGetText, full_path, A
7 a5 J* y1 d' f! w, ~ ; Split on newline (`n)
! k/ V8 ] }8 H( i6 W' y Z7 F6 t StringSplit, word_array, full_path, `n
3 K. ~6 B5 ?) ?' ?% o8 m ; Take the first element from the array
$ e# \" m' }9 e full_path = %word_array1%
& j8 b( j$ P: P9 j0 H ; strip to bare address1 K. U+ D: ]) r; L0 g* |: e
full_path := RegExReplace(full_path, “地址: “, “”)
& D+ e6 W# F, @ t1 w: d+ ] ; Just in case – remove all carriage returns (`r): v8 {8 U" S5 O' C8 ^
StringReplace, full_path, full_path, `r, , all
- t X* b B2 t* W' P! q& v IfInString full_path, \0 d. [: I7 t8 w
{
8 \, I1 {) q& @1 t Run, cmd /K cd /D “%full_path%”
) A) n0 d- O7 }1 F0 ]$ _ }
z# p9 p$ L0 Y) O5 F+ { ? Q, s else n. S( U8 N# e) y! g
{/ c% e% p0 f3 H* V7 } r- j
Run, cmd /K cd /D “C:\ ”
0 ~1 N& f- l5 p, j( o5 ^ }
3 P, e, }7 v. e6 Q }6 W8 [2 q, j3 U' T: E
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 b7 B( v) `4 E( R0 V
这段小代码肯能有两个你需要修改的地方
( [( Q0 e* V0 U3 V$ K1 R7 a0 ` 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 d& M7 ^* J# X 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 Y* q3 o5 j- B9 ? |