此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。: z8 C$ V; s; L
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! L) U6 b: v- p6 r9 o0 u
方式一:+ m' d. [. O7 _- p
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, u d$ g1 }# A& x8 ~* V0 ^$ m7 u
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 E1 p2 ~% J$ i* M HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) a' W- V% V1 ?: Y4 v6 q
方式二:
; d; \6 o$ w) D 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ @6 V `4 g7 Y1 u0 X SetTitleMatchMode RegEx
& c K/ a* g# O, a2 N" C2 E return
7 c9 y- m( c0 t9 S7 ~ ; Stuff to do when Windows Explorer is open
) F4 n6 O/ H, C# L; U ;3 A6 N+ |; W, R6 a% E; C
#IfWinActive ahk_class ExploreWClass|CabinetWClass7 f! t" p: [; E' P5 u% f
; open ‘cmd’ in the current directory8 r/ ~4 e! i1 B: I4 h! O& r; P; m
;! C: j9 k0 ?- @& A5 v% `
#c::$ _+ C4 {& @7 B. D" x
OpenCmdInCurrent()" G3 I& u$ k" L2 ^+ W
return
8 R- T- y# f% D& l #IfWinActive2 \, N5 J1 I. ?, I
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
" @; h' U% }* O; O4 i ; Note: expecting to be run when the active window is Explorer.
9 d6 D H7 V1 E" ? ;8 Y* _2 I& Q3 [! r! ]+ [
OpenCmdInCurrent(); ?7 B7 p) b* Q' M
{
- o# k( F7 d7 t! {- _ ; This is required to get the full path of the file from the address bar, y' W' j1 Q, J k; I5 R; w
WinGetText, full_path, A9 g4 f$ u+ E$ s1 m$ \" ^
; Split on newline (`n)) }0 ~" @# m1 g; B Q
StringSplit, word_array, full_path, `n, |4 o) R- J: p0 B3 R* L+ c1 R
; Take the first element from the array& ~, S' w4 W% Y( s/ Y
full_path = %word_array1%6 b7 w' z$ H* w* a( a
; strip to bare address% w0 [3 E. O; n2 V2 A
full_path := RegExReplace(full_path, “地址: “, “”)# {! J) ?# x/ C' Z" Y4 n$ ?& |
; Just in case – remove all carriage returns (`r)
6 H$ u# q( k; C. P5 L S StringReplace, full_path, full_path, `r, , all
6 O6 b3 H3 t1 |7 L7 f8 {8 K$ E IfInString full_path, \
7 n" g5 L, }' F( h6 ?+ i {
( f$ g+ N9 _; p9 Q. r Run, cmd /K cd /D “%full_path%”
1 ~% Z6 }1 }" n) W; c }3 {7 m P/ F% e/ f2 F( m
else) [* @4 X" L( g. `
{; i( K" v8 o* k3 k0 i+ s
Run, cmd /K cd /D “C:\ ”
& {0 e. C% F1 m8 I0 Y }+ H* F) O2 z6 [4 }/ ]# O: m
}0 T8 ?5 S1 R# s O. ]. L
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。 `/ ^1 D0 D5 A* A5 m' g4 V$ Q# H
这段小代码肯能有两个你需要修改的地方) W, L+ C. P* M, ~6 ?: Z' \, @4 i
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, l Z' [' R7 X; \ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) G: z+ j- V+ R# ^$ \3 P |