此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 o3 Y a( O ]) c, ~# R 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。2 Y5 ^$ @. I5 `* U1 F/ v4 q, Q
方式一:
! z( x7 C: D* o% }& P 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% L" D# M: n* ]& s9 T$ ? 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
: \$ W& i3 f# I8 R% ` HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 X8 k( v6 R3 l7 ]
方式二:
7 j+ \% V0 `0 ] 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:8 @7 K; o1 e% a( e
SetTitleMatchMode RegEx( B5 v7 }9 }& b2 Y7 Q
return+ I6 }, F9 e6 }
; Stuff to do when Windows Explorer is open0 a! g% h, ]$ @! m# K E& b5 k- Q
;1 P; z: f. h# q
#IfWinActive ahk_class ExploreWClass|CabinetWClass$ o* X' V' T# W) E
; open ‘cmd’ in the current directory
9 A9 ?# i3 q/ a/ e ;% e; j3 w$ r7 f! y7 R* N
#c::- Y2 l. Z: e# I4 d
OpenCmdInCurrent()- J$ M& U% ?0 {/ U' a" t* i
return1 s: e5 K* ?: t. n& f2 A& w: [
#IfWinActive8 \; F$ z0 `/ q# U- y
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
5 b+ B9 X) c: m. G1 ?/ Y: y ; Note: expecting to be run when the active window is Explorer.
: v: U' M4 a, q$ S; x* B8 s9 i$ R ;9 I- x# U# N" v4 J7 o" ~
OpenCmdInCurrent(); R0 |5 s0 B2 m4 z# T, L
{& J5 x! z5 q! p% p+ C% J1 K
; This is required to get the full path of the file from the address bar) j* k8 e, [2 e I
WinGetText, full_path, A% @2 e) K" [* Y4 v! \! l
; Split on newline (`n)
7 P e" N$ P H* i( G StringSplit, word_array, full_path, `n
. X, i4 s: r4 I$ [ ; Take the first element from the array! D& N4 e. X6 I: s8 C
full_path = %word_array1%9 D% Z, _2 V3 ]: C6 P
; strip to bare address
( o* M. h& I' L$ a full_path := RegExReplace(full_path, “地址: “, “”)% D7 I$ O9 x) [, I- x+ X
; Just in case – remove all carriage returns (`r)
9 Y. U/ Y8 t6 z( }2 \ StringReplace, full_path, full_path, `r, , all, Q1 j7 i0 O5 @: K
IfInString full_path, \5 b: h) [. d5 X) j1 S
{ X, d% W& s6 L
Run, cmd /K cd /D “%full_path%”1 d/ I5 o q* ?5 T5 P$ C2 h
}
0 r2 n7 F, F( l4 ?- w* ~# x else
. T' O a) m) V8 e3 ? {9 k2 E( |- Q* H) C/ U8 X, ^+ e4 u
Run, cmd /K cd /D “C:\ ”
. s% Z& d4 T; {7 V; c }: ^0 M6 P* y E$ O8 N" X1 C
}# E w# M% I$ x5 [$ M& l" ^8 `- V
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
1 B0 G' M+ p' ` |1 V0 } 这段小代码肯能有两个你需要修改的地方
" Z3 F; Z$ n# E 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 K% n- M) }$ j$ ~! T
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ v6 e9 V7 |2 r) v0 m |