此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
8 m+ H% W/ J" p+ T1 L8 x' K) Y 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。" l8 T6 j) T1 K" \; c
方式一:: m( m+ m% X+ Y3 k
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
9 I* f% O4 g- c* m 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, z$ X( p: Y5 {: h8 W8 q% A8 C5 r HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
1 V* T" f' T$ T% {) x3 x& K% A 方式二:, P' _4 J! e$ B1 P( |% e
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:- W) V+ _# F* w, t
SetTitleMatchMode RegEx3 z2 F! d8 b9 d7 t, C1 M$ N
return/ o& `" U( C" W" K! I
; Stuff to do when Windows Explorer is open) {; w ]3 O+ `$ K& ~" r; |6 i
;' j2 X& q* b: ?" ^- \
#IfWinActive ahk_class ExploreWClass|CabinetWClass
/ n" D1 e, o7 S0 O& r. t& u( b ; open ‘cmd’ in the current directory! Q8 F# B; N; {6 |# v: ]
;
7 q( ~! T0 B& d6 H/ z #c::. V" F8 [* Q7 q
OpenCmdInCurrent()
3 f0 f i& ^ H2 E, W- ` return
) a" o# W" o& c" J" i. ] #IfWinActive" i2 W3 b- m+ w2 V2 x3 B Z
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.; q, v' I5 z0 I* }7 D# x# X
; Note: expecting to be run when the active window is Explorer.
! _8 o% Z0 m3 |$ O6 }. k ;
; Q- @1 A+ Y& w7 G) Y OpenCmdInCurrent()
: X7 _) X3 H- q {7 M2 Y% U3 H/ r# s, ?
; This is required to get the full path of the file from the address bar
( ^+ k' s' x* x3 _" S/ [1 [ WinGetText, full_path, A2 R# g" `7 d/ f; D" W) e
; Split on newline (`n)
- o5 q+ Q( J" H2 c! N( X3 L StringSplit, word_array, full_path, `n1 z+ ~% Q" k# p9 E) d6 q1 K- ?
; Take the first element from the array2 W4 Q/ Q, \4 }# R1 V
full_path = %word_array1%
9 g4 M7 P; q( q6 }1 L* a ; strip to bare address4 g; ~ ]2 K6 u9 f& K
full_path := RegExReplace(full_path, “地址: “, “”)
9 f- g# C* n6 _0 b5 F ; Just in case – remove all carriage returns (`r)
; W8 \0 `5 n% J I! h StringReplace, full_path, full_path, `r, , all
m8 I4 W7 q& w IfInString full_path, \) ?' T9 _4 g1 l0 I8 O3 k
{: L5 R4 c$ \8 U* }; [/ C' W+ }$ i* J
Run, cmd /K cd /D “%full_path%” o3 {) z6 a) X/ z( q
}' x4 c: P- f5 @) u: J* h2 F' y
else" |* Q9 v1 p: H6 C
{
3 D8 z2 p: p* }; W Run, cmd /K cd /D “C:\ ”- Q; J3 B4 C5 O5 G& C/ x
}8 N E6 t/ t, [4 e J
}
# }* D) Z9 S6 `- e1 g/ J 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ h- j" j0 D/ L/ S( _ 这段小代码肯能有两个你需要修改的地方
' u9 A2 |- r! g: A N5 s1 E! y 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键1 g; v# ]7 P1 x# L% L+ N
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “/ I6 X6 `5 Q" s8 H$ c
|