此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% Y* L" j$ ~$ w% J
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, l/ U6 |! \. p* g# c0 v
方式一:" _4 e" D& j3 e. i3 Y( g" m+ x
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
0 i" n3 a+ a/ g1 }, ]0 _ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和 ~' J9 ] \+ f/ ~& Q5 @$ n) v
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。% c# h* ? P/ |+ H& M. u
方式二:' x! }( x& t- J/ {1 ?* v4 t
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" [# c( d( v* Q8 ]* T' n
SetTitleMatchMode RegEx
$ G5 T$ u' u! U$ c _7 l return$ \6 p _& c: c+ [/ \
; Stuff to do when Windows Explorer is open6 h+ m* e2 J; j8 d" ^; e
;2 ~, I5 _2 c2 n: {% t* F) j2 C
#IfWinActive ahk_class ExploreWClass|CabinetWClass5 _4 q6 F( @0 [. Z. Q
; open ‘cmd’ in the current directory
) Z5 V2 E0 L, S x) o ;+ X2 r- S. o+ l( N
#c::3 U# F9 ]5 M4 X4 {" _
OpenCmdInCurrent()
9 {8 O$ c4 X4 H4 o4 k t/ o2 n return- r/ ?% }2 r% E; e ~* {& m
#IfWinActive
1 ]; @" G+ }9 n$ J ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 J, x8 O" A" F# W6 y1 q0 [5 U' f
; Note: expecting to be run when the active window is Explorer.
# [) F% w; Z) I9 _1 n, D ;9 E; T# H) B6 J3 x+ D, P
OpenCmdInCurrent()
; H) K R3 j8 ?" t( j: c. v {% t) n. E' S' Y3 F2 h
; This is required to get the full path of the file from the address bar
% }9 t5 i) ?$ I WinGetText, full_path, A
# ~$ B& }& f# a; ?' V ; Split on newline (`n)
) j" C8 e) h+ k StringSplit, word_array, full_path, `n
- j: `) x2 j j8 o. \; d1 P" z ; Take the first element from the array
8 c; U( D$ e/ i, ~ full_path = %word_array1%
+ I5 D: D7 [4 ~( A: n! }) z ; strip to bare address* l9 _% O" X: Z: _7 u
full_path := RegExReplace(full_path, “地址: “, “”)
' P) c! I3 n$ D3 @( P2 A9 j+ C0 m ; Just in case – remove all carriage returns (`r)
8 m$ ]. N' f! h. S+ l1 V8 ~7 a StringReplace, full_path, full_path, `r, , all! [/ ^* e. ?" \* D2 s
IfInString full_path, \
3 C! Z8 c# {* O* ~ {- D* w' V, y; k. J& D
Run, cmd /K cd /D “%full_path%”3 {' R" U2 w- R9 r" J! n5 a# M v
}
( m! C, g6 x/ k- H4 y) B else
2 H6 u9 `. V* e# W {
6 [' N: C& o+ t7 f Run, cmd /K cd /D “C:\ ”/ k% \5 e2 U! D) S
}
$ r, ^# ]9 h) O4 b. {8 [- I }
# s% F3 x4 R8 m1 w& |& { 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。+ W/ B& ]( z3 p9 `
这段小代码肯能有两个你需要修改的地方
% O7 P& K4 Y/ ~( b! q 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
! v1 b7 E" u$ V( j 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “" Z/ F+ {: Q) `" D/ I: d' p, ~' }
|