此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 `8 A7 E$ d0 g- }; A% ]
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 [) J, Y: p, e! L 方式一:* c, E+ D4 w6 I; S" t0 Z' R
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
/ T" F( F8 j" U: E w% J$ ?, t 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 h4 d7 X# V7 m2 H- ^
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
; l: x% Q4 v% T0 H ^ 方式二:
$ _% ~/ ], F# u2 [$ M/ x 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 p1 e, A! y( @" Q$ z7 N- `# B SetTitleMatchMode RegEx
$ g, R. n" j9 D: |8 g* b9 r return
6 {! c" {7 W: ]1 A4 Q$ C ; Stuff to do when Windows Explorer is open7 e: ]4 V- R0 c7 Q, z
;, p; j9 Z( Q( ?
#IfWinActive ahk_class ExploreWClass|CabinetWClass0 s7 z- C: x6 c p2 ]. C- `: g7 P
; open ‘cmd’ in the current directory
0 [7 r, x3 K6 f! D ;
) I, `/ I3 U p3 t: @; U #c::
4 e! {- O; ]* R7 m# I& [& }) g OpenCmdInCurrent()9 P% a, m' ^ D ~
return
3 F U8 l5 ]9 r0 _ #IfWinActive. |) Y/ \" i) o2 v- L, t
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 y! r4 O" S0 y2 f# I* x4 m' v
; Note: expecting to be run when the active window is Explorer.
9 B3 Q' I0 O. o. O ;% `" U) C9 n- X. I
OpenCmdInCurrent()
9 ]/ q7 L! W0 b0 Y, w4 \- j {
8 }$ U+ B% h- H1 I9 c ; This is required to get the full path of the file from the address bar
( A" ]3 I* X ?! ~9 E. g! r6 g, W WinGetText, full_path, A
$ P$ x/ a# J/ h2 o' Q ; Split on newline (`n)# U' S1 E' X0 [3 |) o
StringSplit, word_array, full_path, `n
5 A9 A4 M! _ g' I# X: N' B ; Take the first element from the array
' W! y: J4 E$ h+ u6 { full_path = %word_array1%( c/ w- F2 X0 x" [: M7 m
; strip to bare address
/ ]. U5 B0 ]4 C# a! m+ @ full_path := RegExReplace(full_path, “地址: “, “”)
9 a& e5 ?- `( I( M! K; H( A ; Just in case – remove all carriage returns (`r)( I" f; o: Z3 P- E, B
StringReplace, full_path, full_path, `r, , all1 u/ V3 ~3 A) K0 @! u9 u
IfInString full_path, \- h" t" K" o7 G. n- _% f- A
{3 g' T4 s1 }9 ?0 a
Run, cmd /K cd /D “%full_path%”
T; h% m2 p Q }( k- B5 f5 w n! \$ p
else
$ C8 G# e* m$ g {0 l, t- u5 C4 o
Run, cmd /K cd /D “C:\ ”; a- U0 Z+ m$ \+ n4 Q p, g( r
}3 ~4 R4 g+ W& ?8 l O2 S: _
}
. G/ R0 C( g2 _- S 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
& X0 U' B, x' V( {7 ^ 这段小代码肯能有两个你需要修改的地方/ w$ G: W$ G5 }5 k
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键: F+ W4 M4 B6 z! U9 O& G
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* F' g' u2 a( \9 {% ^: Q( b, j |