此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
6 C* s) e6 Z, L8 ~# B7 Q$ X 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。$ C5 s% T5 r: F: ^" H+ U
方式一:) t1 I0 d! \6 B. v
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- [( | Z& c' d
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 O; g" M9 x. I HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 O+ \! r8 j1 e6 ~
方式二:0 J9 _* m2 k$ a
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
1 R; R+ E3 E! @& \ SetTitleMatchMode RegEx
) H5 b4 u( M# L return, H s1 q$ C; Q7 ^( @" y3 U+ B! q
; Stuff to do when Windows Explorer is open
) @) O! k' F4 N' |0 a) _( K- M ;
' `4 E% L, z% N$ v5 U* o# r* k #IfWinActive ahk_class ExploreWClass|CabinetWClass7 k; J3 k' _* l
; open ‘cmd’ in the current directory
' t9 F5 G+ @- y3 m) t ;& c2 T/ q5 H4 @0 V* u; P3 c
#c::
# b) r q- i; V) f OpenCmdInCurrent()/ `2 c% G# v5 I
return2 Z. k" D, x; I" ^8 k
#IfWinActive7 b B. z4 o+ s$ n3 F+ G( |+ Y6 f4 C
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.9 h( t0 W' X9 r
; Note: expecting to be run when the active window is Explorer.. u& }9 c+ p+ v' R8 k0 n* ^
;( H" i1 r d% K* w+ T
OpenCmdInCurrent()5 Y8 F+ E2 {# j' A/ v5 h4 t# H
{
/ g4 ~8 T/ o; M3 X# t ; This is required to get the full path of the file from the address bar
$ r4 e+ d7 e2 }, p7 w WinGetText, full_path, A5 D' V8 J4 `" ]# \ _& K/ K
; Split on newline (`n)/ N+ S# e- z/ F
StringSplit, word_array, full_path, `n
* T% D0 _/ b* o3 I% r ; Take the first element from the array" }8 l# `+ C) _& z: z
full_path = %word_array1%
! h6 A z! P [ ; strip to bare address7 J3 _( M3 f* R( w& ?+ {1 ~& V
full_path := RegExReplace(full_path, “地址: “, “”)6 y* T& [# H% K1 ^1 b
; Just in case – remove all carriage returns (`r)) R1 D' H: o6 ^- m Q
StringReplace, full_path, full_path, `r, , all
+ M" S; h- E* k* D5 B9 a; X IfInString full_path, \
4 A( g5 L2 _7 s5 j5 s* o) s7 C( j {
$ A* _; v7 R( {# Y; o Run, cmd /K cd /D “%full_path%”
; h/ B5 {% k1 I+ ]# H2 Y/ m$ b }- O b$ k3 B4 I9 G3 N& B0 ]
else
# L& D8 L2 _. X7 _" u$ C {
8 M; o* {- t( _5 A4 S6 z Run, cmd /K cd /D “C:\ ”
4 q& A" U* [1 h# E, K }4 X6 \7 ?9 P5 D. l E. X, R3 A
}& l. t7 Y; C; u% }/ p% `, x) k( g
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! Z; u: o2 v: Q6 F
这段小代码肯能有两个你需要修改的地方) |& c8 N" `7 t; }/ R$ L! [
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键% x% T' a" _2 F& z6 k% u# \
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ e$ b% d: w* P O! f, w |