此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 b6 L: {! {; J/ p 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。1 n5 u( ~) M+ I' V$ S6 V# }
方式一:
- B" y. S$ v. F' X& x3 m3 h0 Y 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
) K/ Q5 L# t9 k! o9 N 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" S* P7 V. _% t5 v
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
6 Z0 }) m* {0 ` 方式二:
, V) b \; `. m1 h8 G v 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 v7 i ^2 F0 @( }0 F
SetTitleMatchMode RegEx
8 F; q+ L* Y9 Z. y/ i6 g. u5 B o! e! S return$ e3 K7 y( J! i) O$ I5 ]
; Stuff to do when Windows Explorer is open) B1 }2 L! ]( D% _( Q1 u& U! I. P
;2 t4 C. S6 `4 {# D' c
#IfWinActive ahk_class ExploreWClass|CabinetWClass3 g0 O y3 g8 }/ q- c
; open ‘cmd’ in the current directory6 e! q% k2 o) ]! C/ U) A* l
;% x. ~3 ~4 F) X8 c
#c::, ~# U/ m5 U, ?! |, w. @! O
OpenCmdInCurrent(). A1 h+ ?8 u/ {8 o
return
1 a6 @8 { I3 d2 c. L# f- n2 G- C, c #IfWinActive% I5 @% v/ l, f' L n, J
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 g r% I0 l) P) u0 J" f: M, O ; Note: expecting to be run when the active window is Explorer.. u! Z( F- j0 o7 Q5 ?* E5 T, _5 Q
;. f- R1 E- {( z- M) X: N% i
OpenCmdInCurrent()) X5 q% h2 t# w1 ?* M
{- @6 o% R, r, X
; This is required to get the full path of the file from the address bar; `1 q4 y# `3 h. @* W
WinGetText, full_path, A) u5 j- M) q A6 x+ }
; Split on newline (`n)
* K8 s$ R8 ?2 t: F% z- l& s2 d! l9 F StringSplit, word_array, full_path, `n9 k/ C2 F* I" ? `. J: r8 Y; c
; Take the first element from the array/ }" O3 X4 W3 c b/ F: B
full_path = %word_array1%3 E$ h/ i) d% v$ m/ {/ m; g8 z7 p4 }
; strip to bare address
+ k' m3 ~ F% |6 {# L% H full_path := RegExReplace(full_path, “地址: “, “”)
7 F, k& J& L8 N; O ; Just in case – remove all carriage returns (`r)
- ?1 k6 }$ y5 {8 c, T9 q StringReplace, full_path, full_path, `r, , all
: f- \/ D( T$ m IfInString full_path, \9 r# ~, w. f9 Y; [, f! k* h
{* b. \* q& z# S/ R! M* f7 Q, `& U
Run, cmd /K cd /D “%full_path%”- z7 ^& u) p& {8 L
}/ W" E/ h9 i/ K7 V2 ?& R" \
else
/ y8 W' u C h( {- h* ~* K: e7 p {+ N9 W. w2 y! b; ]2 o1 F9 s. I
Run, cmd /K cd /D “C:\ ”/ Q$ p& C- P" B
}
. _$ }* [' n* ^- D( L" o }7 I2 C& j0 j5 r: E# h& D8 g2 [
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
& H1 u7 n+ A/ }' J 这段小代码肯能有两个你需要修改的地方
; z: H5 I! }3 N3 J 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ w2 G2 [* v- ]. J0 D
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) V& z+ ?7 R _- U |