此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 \; z8 s `2 U# A0 \
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* G8 B) h9 |" t9 n
方式一:& N* L& [; r# s& G
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, I$ W2 O4 h4 T
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" K$ \+ D, w3 I; |& q- m9 Y9 _ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。9 D1 V g- `: E/ z) o. S
方式二:
7 S |; E* } w2 [ _ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:' g8 s; J! {7 t
SetTitleMatchMode RegEx
' M! F$ U# b Z9 T8 W/ R' Z6 a6 n return
' {; i2 q% ], P2 w+ W# z/ w9 r8 }) i0 o& J# I ; Stuff to do when Windows Explorer is open$ m! q+ _2 V0 Q0 Z: v9 L7 h' [
;$ P2 _( l3 ~/ o0 S$ V5 Q. x
#IfWinActive ahk_class ExploreWClass|CabinetWClass
* n( ?& ]; U8 c- U! h3 ^- r ; open ‘cmd’ in the current directory
0 l7 b0 m( i! ?' }4 M& | ;
! W5 `( P* c, k #c::
j( ?; U& [. T* ?" \ OpenCmdInCurrent()
9 |- U/ K6 V$ {3 D/ n! u y return
6 t, M% L" D% U- D #IfWinActive* u+ m3 U5 R: ]5 [
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.2 q. v3 `# m2 _3 U
; Note: expecting to be run when the active window is Explorer.5 f8 ?) R; A& ?' c
;
& [* A/ ?) V/ Q OpenCmdInCurrent()
' _$ b2 N0 [; G9 H {
% v& s1 H8 K, z ; This is required to get the full path of the file from the address bar* N" K3 h5 m {0 z# M
WinGetText, full_path, A
" ~9 ?7 k0 ]9 `- H ; Split on newline (`n)/ r4 J; T1 P, g- I
StringSplit, word_array, full_path, `n
) ?# H" M2 \" i0 h6 K; j* C. j, w ; Take the first element from the array, }6 M. ]7 }: J, E+ u6 }' t
full_path = %word_array1%0 D1 M; r8 W# q6 Y+ e& l& ~3 E6 u
; strip to bare address
0 h' j" }( e; Z Z9 F0 m full_path := RegExReplace(full_path, “地址: “, “”)! p4 D0 e1 ^/ P! H9 Q
; Just in case – remove all carriage returns (`r)
/ T5 F% p. ]3 j( P5 s$ p) c StringReplace, full_path, full_path, `r, , all
& m$ @* s, |7 C IfInString full_path, \
* J- d0 a2 @$ \. l {. B5 n: F0 U! _
Run, cmd /K cd /D “%full_path%”
$ {3 B; z6 ?$ O) c7 ]0 w }
& O( O. w: V' \$ Z7 o else
" [6 C& p" v* L% c9 ]- p' q- R {6 F8 r6 {# d+ ^3 K' i0 j
Run, cmd /K cd /D “C:\ ”
: { u* i( a5 k" a8 Q }
$ p* x- W' S! k1 q& J6 z }
* @6 j" w" @& S9 L3 d- j 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 W% A- c ?1 e2 \" _+ C* } 这段小代码肯能有两个你需要修改的地方
6 c0 @0 w1 k" y4 T3 M7 X" l 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ i6 [) j2 M! o" K4 }3 _
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 s) I; }/ [( t) j1 { |