此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
# J7 I' k: ~- E/ ^, U 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
Z6 y5 s2 t7 f 方式一:
3 R8 g! e; B2 ]& F F0 D 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 I, w. g8 S$ V* H9 v/ ^ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和, |3 L) l5 @. C* J/ G- @- s0 U. ]
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 X, f. ^9 S; H. \ 方式二:
" _) o# y1 R8 P8 F0 y4 M6 m' y 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! E( T3 X I: {; T* o5 u
SetTitleMatchMode RegEx
y4 g, E- D0 ?/ L/ b return- ], l) w5 ?2 J" w
; Stuff to do when Windows Explorer is open
0 n) z0 _3 ?5 Y ;! r% b5 G: s, M2 |. f
#IfWinActive ahk_class ExploreWClass|CabinetWClass
% f S& w* L1 [9 k p, R8 S7 _ ; open ‘cmd’ in the current directory# ^) L# _4 O4 R% w2 E+ x
;$ ^ p3 Z4 f! ?: O+ a9 N
#c::
y, D1 \! f1 \) c: s8 |0 v3 P OpenCmdInCurrent()
5 m- h- b i7 g return% @' G+ R6 n! M% r$ [, x: T* C
#IfWinActive5 |! D {+ D' t3 `8 m5 [! x6 a- t
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.- C' ~3 j: n+ A( N5 n
; Note: expecting to be run when the active window is Explorer.% \9 W# Z3 a c! p* f; d
; t+ t: s0 e* l5 X& M
OpenCmdInCurrent()
9 ~, ?: v5 o# M8 M& |' ^7 S {7 N/ Z! i& V$ ^
; This is required to get the full path of the file from the address bar
+ N, u) R, v0 n7 N. h WinGetText, full_path, A1 u5 g4 h/ m. I- g8 s" H
; Split on newline (`n)& A/ ^, @$ W" g% q! W ~' U0 y
StringSplit, word_array, full_path, `n! M2 Y ]6 l5 T. E
; Take the first element from the array) U3 z2 E+ ^7 f1 G4 c8 [
full_path = %word_array1%
" R: ]8 P* C1 g6 R0 y ; strip to bare address6 d" R+ J# z, o. _8 Z4 D# {2 f+ \
full_path := RegExReplace(full_path, “地址: “, “”)
. F+ n" z& U" k- q. l- ~& m! } ; Just in case – remove all carriage returns (`r)
6 _+ w" F1 F; Y/ O2 B# D7 _, \$ v" ^; R StringReplace, full_path, full_path, `r, , all
4 r4 b& g3 j/ N O IfInString full_path, \# S9 o) b' y, J x1 {! ]# m! H
{
& O/ h' V3 C8 {: g9 a6 x# M0 _ Run, cmd /K cd /D “%full_path%”. S" {' U c9 w+ |6 \3 {
}
4 B/ s& c- p- O else' Y+ q% \3 I9 t/ f
{
2 g/ i. S5 Y* Q5 @* A5 U4 h- J1 P Run, cmd /K cd /D “C:\ ”9 _6 }) ]& J# \! ]) a
}
) @3 n( h& H6 | }/ [' Y& w( L9 A! k
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* a8 V5 b" ?" O
这段小代码肯能有两个你需要修改的地方# [% X' s* b. a
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ _0 R/ Q. u2 F, |8 p6 [ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 \& C2 h- }% {- q% K2 s |