此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% [0 F/ F2 k* E' @% J8 S+ q- r
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 l G: Q9 @+ [; i, S: b' } g
方式一:
u; w0 i9 W2 b/ X" l7 O& O* { 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 w7 P4 |" }$ t) J$ R$ k
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! J9 s' `6 |4 u" g+ I HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。 n2 }. y) }: D3 O# o0 ?4 @; r
方式二:) m7 B' A! P( O7 [
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:2 M- g: l0 y7 ~; S0 ^, ^' a3 {4 l
SetTitleMatchMode RegEx
7 _9 |! j) M! F- Z6 n return* T; F" U& } ^/ V8 p+ O/ U( @
; Stuff to do when Windows Explorer is open* M3 E* a B% B5 C+ P
;3 x; j8 |: k0 A. D
#IfWinActive ahk_class ExploreWClass|CabinetWClass5 S5 ~# x8 a! w/ U
; open ‘cmd’ in the current directory( n/ V3 t% a* w2 l3 L2 G3 k
;
. T3 q0 |- n! q #c::
4 p0 M2 n7 W; p2 f OpenCmdInCurrent()
) T4 ]+ m3 l! T" {9 t- s# F return+ \; b5 z$ k3 `
#IfWinActive
# B% p" e5 m) Y6 ^ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer." b s6 @% {* ?6 y0 H3 m
; Note: expecting to be run when the active window is Explorer.: k2 p6 |8 [- H: }7 c. T: @9 ?
;& z# n7 Z& w7 ]; k; h6 T. [
OpenCmdInCurrent()7 W- E: q4 q8 ]' [; P/ j
{* ^: \. G' L+ }5 d
; This is required to get the full path of the file from the address bar) X4 W9 N- z+ b, ]! H* ~- q; X
WinGetText, full_path, A
1 B$ i. @ l' W' V3 K4 T2 i* ]2 e ; Split on newline (`n)
5 f2 j+ h1 s! X+ e$ J StringSplit, word_array, full_path, `n2 w! [1 F% `. \+ f
; Take the first element from the array
( p) S- w) H, B full_path = %word_array1%
0 g P5 \ _8 r k/ Y ; strip to bare address
$ B6 f- `' F! [& X8 t7 D full_path := RegExReplace(full_path, “地址: “, “”)
: n% v+ x" @* T ; Just in case – remove all carriage returns (`r)
. w0 _% Z2 t$ j StringReplace, full_path, full_path, `r, , all
3 A. S% S) f' K( j6 u, X IfInString full_path, \
; K1 w$ q4 {1 P {
0 K8 e2 }$ \% u4 Q1 Y Run, cmd /K cd /D “%full_path%”3 ^5 c4 I3 {- b5 @
}
! M0 d& s2 J: Z+ k$ d. p else* `3 j0 C. x" f. U- v4 x ]: D# A
{2 Z x' Q2 S& y5 r9 z5 p
Run, cmd /K cd /D “C:\ ”
. B0 G7 T n, ]: g8 R( V/ } }; a3 w' S) t9 W6 x
}6 H( |2 H$ h: l' V9 b; O
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: Z$ J4 }) j# o2 k( J5 S, m 这段小代码肯能有两个你需要修改的地方7 O; V+ x( R* z" H2 Y% N( r' d
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ Y# p, R/ p8 U9 m7 _ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 Y. M) k; y/ O: @: J
|