此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
" O* }( z1 N2 }+ C$ c' C 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
: J7 z6 c* u% d; x 方式一:
8 O0 I( ^ {4 e+ f+ R( | 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,5 t" L4 N( j2 p' k% g, E/ U& ? t
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
- i3 k2 z* s, I% j {& d7 i HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。! M% W# w, E) z$ x) J- b9 H& O' o) S/ D
方式二:
0 b) m( X$ E0 ?+ g0 ~' U" h/ H- _ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
. V7 \& k9 H k6 @5 E SetTitleMatchMode RegEx
4 G% u: q# e9 I$ O; g return% t0 @# s6 K {; v
; Stuff to do when Windows Explorer is open& l: a+ u# b5 ?( S$ K* n
;9 X# _( ]* K* y- A2 @( G( e
#IfWinActive ahk_class ExploreWClass|CabinetWClass8 T- h. {- K P# V) t4 f
; open ‘cmd’ in the current directory
2 @& g0 h2 M# d+ g0 D ;! ?5 z( ?; q" r' j
#c::2 j, l% v/ x: J, j C3 P
OpenCmdInCurrent()3 [( I" Z; S1 p; n/ E! D
return+ \+ X3 M. v% ?9 {3 l
#IfWinActive7 r* W8 M2 E7 t9 l
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) l" O- R3 w$ K. S* o& j; a0 Y. E. x
; Note: expecting to be run when the active window is Explorer.
: v0 R& {! }* m* j- @& e& x2 s ;
) q+ E- i" v3 [, G" ] OpenCmdInCurrent()
" m2 d+ I% y b$ t* z" s; [ {4 c' R9 s+ Q- Y
; This is required to get the full path of the file from the address bar
8 L0 ~8 T* t+ r9 D- H6 J7 I WinGetText, full_path, A! ~) x2 m @1 \
; Split on newline (`n)! d+ k7 {+ u- z
StringSplit, word_array, full_path, `n/ C# }# x6 R0 c
; Take the first element from the array
9 Q/ T4 [3 _! k5 h full_path = %word_array1%$ p# \ a9 V M0 k- f
; strip to bare address
" |, G0 m+ U. O2 s1 [* Z) e I full_path := RegExReplace(full_path, “地址: “, “”)$ u9 V3 Y4 B0 c
; Just in case – remove all carriage returns (`r)8 V0 w0 D) h- t& [7 [: Y: b
StringReplace, full_path, full_path, `r, , all
( O; ?2 B9 Q; Y, w# `; v: U IfInString full_path, \
9 c6 l4 ?( `& x5 `" A* e a" P4 b8 R {: p7 q. C+ z, }" V, ]
Run, cmd /K cd /D “%full_path%”; p; e1 J& r7 `; m7 t7 @
}
' a% ^/ F/ S- n, C! \( b else
. V( T$ b" y# D ]4 Q7 g3 I {
3 h4 E" a2 @3 x Run, cmd /K cd /D “C:\ ”
: q0 J% A. Q/ ] x# W }
+ {; Y4 z. i3 l) b' q% [ }/ ~2 v5 Q' z3 C- z( M
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) V; P7 R1 {' `& U$ M! a. A
这段小代码肯能有两个你需要修改的地方
# ^; R; ^( p; A( x- Q. I" v 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键8 _9 C& _+ M2 x8 R- i7 J
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 o2 Z g) n6 I- ?1 `: A6 c |