此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 `. T: X! }! u1 p0 C9 z: I 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。 H- x% [4 y, W6 Y
方式一:) Q+ i3 p% K# x# ^# k6 j: r
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 D, Q" e, ~' w! |2 V# m, B! y7 ?1 |
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和 D; y4 X2 g5 r: D1 V: d
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 O/ H$ K2 r% a& L- m1 j4 Z; t
方式二:$ k. F) E. z" {3 s3 q' Y
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
5 m8 Q; ~( J. E SetTitleMatchMode RegEx; x8 @# m! ^& Q- j& p8 S
return
! U# t$ g3 x+ Y% d5 a8 K ; Stuff to do when Windows Explorer is open
; S) a7 b c8 |3 J6 p ;
[: ]6 y( O& X0 s! S" z$ I# j$ S #IfWinActive ahk_class ExploreWClass|CabinetWClass9 k2 h2 c' y. Q# g( |) g% L
; open ‘cmd’ in the current directory
5 G" W+ \" T$ [ ;
' }& c( w* S/ a9 K" L9 X/ d# E6 l #c::
' y% {# j. k+ k) X0 n! } OpenCmdInCurrent()
, g' f! H) |# \6 ~2 S w3 R return
1 q9 z% ^" M$ t #IfWinActive
6 z% L% Q* p v* R6 N# q. f7 { ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.7 |; D; }; z0 \. o+ E9 l
; Note: expecting to be run when the active window is Explorer.& d% z0 }3 y a+ d" ~5 P; @# ^( v; K: ?
;6 D/ O2 s0 Z0 a3 _& x( N; A
OpenCmdInCurrent()
# ^' x$ k; |' C: a! M) M {
8 q6 ]) _( n3 P ; This is required to get the full path of the file from the address bar9 G- a$ t" v0 G1 i; h! }1 `: B
WinGetText, full_path, A3 |9 g5 i6 O7 m- d$ o! K
; Split on newline (`n)
; D% i3 n" y) a, ~5 t+ K StringSplit, word_array, full_path, `n9 A0 u- `1 R: ^; z, P; }" f8 e/ ~
; Take the first element from the array' `- f" u' Y) ~
full_path = %word_array1%
- W/ B3 n( M3 O: z) K ; strip to bare address
* o! n! ~. r' w8 p9 I1 s; O full_path := RegExReplace(full_path, “地址: “, “”)1 M) O* Z$ v |1 z% t0 F1 N$ J
; Just in case – remove all carriage returns (`r)
1 @$ e7 e+ g: t8 K: c StringReplace, full_path, full_path, `r, , all
6 ]1 V+ ?2 m5 z" w4 Z IfInString full_path, \
. P5 D+ @: m" F {
}/ U* n2 R: K3 j Run, cmd /K cd /D “%full_path%”
( M2 E7 y% v" Z }
" X9 e; ^ q% U else
! P# l) i7 ? u' C1 P0 u7 V {
9 S$ D% a2 b6 O) D1 u Run, cmd /K cd /D “C:\ ”3 U) K0 v6 w! j
}, W! Q5 x; e7 t5 R: s
}
/ a" I- X" g5 N/ _. W- M5 z 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。 M& T6 V9 g" }) d9 d9 D! P, }
这段小代码肯能有两个你需要修改的地方
2 C- y# \. S# ^5 s( `, _3 L1 D 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
y# f8 f" N5 y" ~ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
' r7 X5 h) @- v6 y |