此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。- j/ _. j- U* O$ h
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 I4 x% q, D# F/ p
方式一: D+ u. p# {( C7 W; z r
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ f8 K0 w2 ], S. n' v2 {
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
# o* |- u' Y0 X) M! F2 M# o3 o% [ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。9 N6 F( b k" {9 Y
方式二:
' R- ^" E# f8 h( n2 j, P" A) T 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
, ]% K& a8 C: G0 k1 m) g" o SetTitleMatchMode RegEx
; R- V0 R5 |, T: _5 Z return
% J# e m* g2 D, D$ @ ; Stuff to do when Windows Explorer is open7 m* `* V5 S9 g# |% |4 V! I, I3 s
;
0 D% y) a( C) ?4 ~% q# ^: C: W #IfWinActive ahk_class ExploreWClass|CabinetWClass% n3 o, ?! `/ ^; t6 U* ^: L
; open ‘cmd’ in the current directory, {$ H6 Y6 \+ _& s2 _/ c* X: v
;' ]- d* y8 A D2 K( D% g
#c::4 L: C* i8 u0 C) o5 ]( d
OpenCmdInCurrent()
( Y, m) v! v; Q$ V" M. { return
, s# h3 }9 z& q( B! [. M- z2 T #IfWinActive+ ^2 a4 w3 Y9 K2 l, D5 ]8 ?
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.% j' V% U M7 s; [# I- _
; Note: expecting to be run when the active window is Explorer.
% x: ~. P% f) y1 \$ ~2 y: \1 W& b ;( w- O3 \7 `+ K+ r
OpenCmdInCurrent()
# O, ~ k6 |# b" V$ s {
! f% A: O* v% i) }" T. X ; This is required to get the full path of the file from the address bar
Z+ |& ~5 p& i: ]7 @' R WinGetText, full_path, A
- K& }& H% U" u9 t, L, j0 d ; Split on newline (`n)& g' g( U# I, e, J" ~2 y
StringSplit, word_array, full_path, `n
1 B0 `+ V Y/ O8 M# l3 O ; Take the first element from the array+ g& H% D4 {$ {, T& H3 I/ \
full_path = %word_array1%& a7 c' N/ f( ~% s" Q) r
; strip to bare address
% e/ ?, U7 ?: w full_path := RegExReplace(full_path, “地址: “, “”)
1 u0 o3 G: R! S% m1 I1 T. \ ; Just in case – remove all carriage returns (`r)
! o: {/ A9 d" d! b$ g2 g( Z StringReplace, full_path, full_path, `r, , all
' a! u$ z; T7 b; ~0 A1 @3 K3 x% V2 l IfInString full_path, \
1 M" x) T. G F0 A& c# r' t# s% v {
1 }4 c. q$ t- C/ y5 y Run, cmd /K cd /D “%full_path%”
9 @. N) p7 U* z( Z3 d7 M }! f! W" Q$ c% c% U
else6 s5 v+ b! J6 t- o( l+ S3 F5 Q" z. Z
{9 N0 |& ^1 W) {: p: B6 O
Run, cmd /K cd /D “C:\ ”9 D& L. f4 P; V6 } J
}% I! Q3 P/ c% g# L
}9 |9 i: d: |0 c+ ~: u. V+ g
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ m* t% p+ c: \) ] 这段小代码肯能有两个你需要修改的地方* w. d& t4 D( v Y6 H; {/ e
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& o5 G! p7 V9 I
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 |# O5 P3 q5 D3 O& E |