此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。0 F+ v8 m3 X, h' }# A1 h. N4 C
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
. e) F) \8 L8 Q 方式一:
. ^' l4 o S4 K* t! _" c& Z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 D$ h( L" c" a( F# @+ v
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和1 [; ^" x% M4 J5 g) M" ~! T
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
# T- r0 Y0 k6 J. @: ^ g6 x 方式二:
( v# R$ q( F7 O 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: r/ Q; ~7 U) i6 Q( | B" h
SetTitleMatchMode RegEx1 u7 |* C% y5 L/ d, N
return
5 U _+ _6 d8 c+ R" A( f ; Stuff to do when Windows Explorer is open
) z, ^* [6 s* Q# d$ w8 y ;1 j. o/ e* n: r" L {: x
#IfWinActive ahk_class ExploreWClass|CabinetWClass
X) |3 T8 A. Z8 R+ l ; open ‘cmd’ in the current directory5 d2 T/ o5 p8 ?, J9 m9 ?& i" w
;4 U; V, Y6 M# A: z4 M8 @ w
#c::5 t+ A' i; \& N7 D' b
OpenCmdInCurrent()
+ C8 `' T# k- y2 T# O return
4 t9 X( M, Y1 A: g #IfWinActive
/ O s. v: n, p8 a4 ] ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 p9 u: k! \7 _" w! P- z ; Note: expecting to be run when the active window is Explorer.' Z$ v+ l- ~7 Q: }9 q& t
;
; Y3 ?- w1 G: U# ~2 K8 k5 E OpenCmdInCurrent()- M; Y3 g6 k/ u( D0 K
{9 @. I" k9 i. a, M4 V: A
; This is required to get the full path of the file from the address bar+ R5 }/ H; |: ^+ T" b. D
WinGetText, full_path, A7 A4 ?* O4 v1 X H \
; Split on newline (`n)
3 m' W4 X: N3 z# Q) c _9 P9 D StringSplit, word_array, full_path, `n
6 ?8 |8 a3 F1 f3 b& J ; Take the first element from the array- N5 a: W: S2 A* }0 P m% Z
full_path = %word_array1%
5 L# g" P0 r9 h3 |9 o6 i ; strip to bare address
+ ^$ l) K/ w0 k D' G full_path := RegExReplace(full_path, “地址: “, “”)8 l+ Q2 H0 s' j! p
; Just in case – remove all carriage returns (`r)2 a& B |2 W$ t7 R6 u( o( j5 x0 }9 u
StringReplace, full_path, full_path, `r, , all. {& ^9 _( Z; f- P
IfInString full_path, \2 B$ h5 @. T' | r1 X( F
{, K# k& ~1 v3 \1 d4 e! ]
Run, cmd /K cd /D “%full_path%”2 y1 n6 e, Z7 K& X
}
9 E3 U7 n! ~/ a: f \8 d' ] else! D4 A/ x) A% x) _* y4 C7 F8 g
{
0 j8 A8 s. Z* T7 S0 c Run, cmd /K cd /D “C:\ ”
4 m1 q. C6 h* A& R7 a }
k8 l; T# a. d" M3 l }& C u+ N9 Q% a* L8 M
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
, G$ @/ j5 H" x8 S 这段小代码肯能有两个你需要修改的地方. E/ u3 H4 ]6 _! R) _: Y) m! v
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
- {/ T, X, ^2 A @: D 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
& X0 l( v0 x5 L b1 B |