此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。3 s0 X& a, ^; ?2 m, C: m
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 |6 f4 Z) y3 s( `) Z; L
方式一:, q! { \( f4 c5 e4 N" p
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
, @8 E8 O8 B, |* [. s# g# [ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" O6 i' k' ^. N. N; [3 `* X
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。& @. A( |. D0 c! a3 G$ b, c
方式二:
# D# @/ a6 n5 G4 v5 r& r 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: [' l" t+ H: J2 n
SetTitleMatchMode RegEx
" [0 u- {6 a- J return
3 q3 r" [6 t7 D/ A* }% h) u2 c- y0 y ; Stuff to do when Windows Explorer is open3 J% h* t! Y: } H7 s) O7 U+ b2 ^
;: ^ z- E0 F% {
#IfWinActive ahk_class ExploreWClass|CabinetWClass
! [ N# G4 h" n/ `" F ; open ‘cmd’ in the current directory5 `+ E$ M {: i& g6 E/ r
;/ ^2 W6 `2 u N4 V2 q
#c::$ f! ~- v* w$ I5 O h# z# ~
OpenCmdInCurrent()
5 h* C3 K1 j" I& y( p return4 S& M4 a& L5 N$ A
#IfWinActive/ M& F) O) A" u/ K D \
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.1 R: B+ w0 r& m: f" O* ?
; Note: expecting to be run when the active window is Explorer.0 m' w- ?6 O" [' `2 C
;0 s& A& Q$ z7 }
OpenCmdInCurrent()" D" J' W* q( ^" U
{$ r1 m4 d4 M+ h3 U6 @& [& o: I
; This is required to get the full path of the file from the address bar0 \- n4 n* A3 |: V$ V% `% [/ X1 |
WinGetText, full_path, A1 U" C, ^/ k8 L* w
; Split on newline (`n)
0 D- s6 N3 j9 K q4 p8 e StringSplit, word_array, full_path, `n6 y' T, {. A7 ~
; Take the first element from the array
& u- H( i: k6 n0 C5 H full_path = %word_array1%
1 G# D: l, s `* Z- y3 N4 C2 U% A ; strip to bare address
8 e2 i/ s1 H# J full_path := RegExReplace(full_path, “地址: “, “”) m- f! K$ x, ` ?
; Just in case – remove all carriage returns (`r)
; N4 i$ i$ ~& m) K! U! w$ U: d StringReplace, full_path, full_path, `r, , all4 H: o5 P8 x' o2 G: ^& ~, s0 `# Q7 j
IfInString full_path, \
5 m3 e0 ?# k6 R3 {* t {
; u7 ?/ V* W% ~6 s: ]- y Run, cmd /K cd /D “%full_path%”% B1 E |* ?+ ?: @) |# {
}; n) H9 }1 x% O9 p/ m% n" ]
else
, q$ _/ c% Q& o/ T# t, C0 _ {" p' c7 j' I4 K7 _5 o& f
Run, cmd /K cd /D “C:\ ”
3 q7 D1 p2 R% V* r; o% G1 S }0 |3 s9 E4 M! a; q6 ]. U" e0 L
}& c) S$ c, w& Y& [2 r6 h( y
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( v. R$ _9 \6 ~" P% \6 J 这段小代码肯能有两个你需要修改的地方8 N R- E" s! W% [1 _
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 s/ `$ O5 a% g4 V7 r, u3 Z
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
0 g1 v$ t' @ D% O8 u4 n1 Y' O. r |