此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 y& p( R! b$ o5 Y& g 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. v+ R e9 }/ u
方式一:
7 ] ~# _% {) o% a$ t 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( @+ S# n+ ?$ {* D4 H- P# G1 G
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 l5 g4 I5 M4 S
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。! l* O0 J$ K. R4 ?. G1 h; n7 o4 h
方式二:
8 n& ~" s+ x4 G 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( U: y7 H1 v) x- e& n: o SetTitleMatchMode RegEx$ i) r: {# p: H0 i8 I2 M1 v
return
2 Z8 q' G _; k$ p. ?3 B+ t4 A ; Stuff to do when Windows Explorer is open
8 q& S! J! V' z. ~" Z ;
# I2 W6 C, @/ l8 B" u/ g" M3 O# C #IfWinActive ahk_class ExploreWClass|CabinetWClass% f5 A4 B7 X5 {; j
; open ‘cmd’ in the current directory
K1 ]; N/ _- l/ D, R J ;
# \0 Y0 q1 D1 s/ K4 b #c::
r/ n; E0 h1 \ y" d OpenCmdInCurrent()
, B* X$ H& k' ^* o- s return
( E2 y; _$ M: J2 W #IfWinActive
/ c' k. r2 v3 @% J8 \) `' h: a. Y" h ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
# F+ a0 j5 x2 f" `: V7 o, J% O( x% E ; Note: expecting to be run when the active window is Explorer.
; Z- G* K( l: k# J+ s1 a ;- M* E5 o$ S! N* C. H" C
OpenCmdInCurrent()
! B3 K u2 P5 @6 U G {
0 Y, Q* i+ m4 `( C! \ ; This is required to get the full path of the file from the address bar
$ c# K! _' d5 `: o" S WinGetText, full_path, A
9 {* `$ b) E! b8 C/ s8 J$ M4 Q ; Split on newline (`n)
; c+ ]2 p, P0 H1 P& A" }" x/ e0 ` StringSplit, word_array, full_path, `n r0 M$ S$ J3 ^8 y; x5 [
; Take the first element from the array6 y9 |: [+ u$ G" M5 W5 g
full_path = %word_array1%
- v2 Q$ P- L. D: m1 W' b ; strip to bare address
; Y8 L _1 U; O& ? full_path := RegExReplace(full_path, “地址: “, “”)! b! E+ F& l; K1 j0 X
; Just in case – remove all carriage returns (`r)
; \% {: W; P# Z5 p. y StringReplace, full_path, full_path, `r, , all
4 E( U' Y' @& \7 e IfInString full_path, \( r+ n% A! N4 W
{- o0 Q& ]: k" I' ^
Run, cmd /K cd /D “%full_path%” O1 r/ X( u5 o# P' P4 \
}
' s" W- `( }; R. D' { else2 x$ Y: W# ~( m
{
6 ~2 b# B$ c0 T# } Run, cmd /K cd /D “C:\ ”- v4 u9 s0 j* H3 f
}, w4 D) T( y: f6 Y+ |
}
; o6 Q! \9 W. Z1 I# x3 e- b2 s 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
6 B$ m6 y! I4 D 这段小代码肯能有两个你需要修改的地方7 _8 F, X' j. h
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键* M; ]" {1 b" ]; F6 i7 H0 c6 P
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “0 d1 u3 x6 y. d
|