此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 }1 k4 r9 A6 H2 q 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 [! k" ]6 P- t' r2 H
方式一:/ [1 [9 C% K2 \1 T9 k
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ p, B$ V3 T W" Z$ h) Z
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! O2 R% Y+ r8 @0 ?3 ?( z6 {- ]7 p; V A HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。$ s% t& a1 b! H7 }2 A0 v
方式二:
9 o1 f) K/ C9 n& c+ N) a5 _ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
[$ Z+ V4 V$ [" v. b SetTitleMatchMode RegEx( O9 Q' Z# y7 J' I6 g
return3 u& j H& x' s; E1 D. C$ D
; Stuff to do when Windows Explorer is open
* o- C3 f, O* C0 _2 L( J, h ;
# M7 q7 y# L' J$ v# S. `3 `/ z9 N #IfWinActive ahk_class ExploreWClass|CabinetWClass1 t/ n+ w7 `6 T: G7 ]5 o
; open ‘cmd’ in the current directory4 s. y# K7 C/ E, B
;& _$ e* H( @. o2 M
#c::
6 X# ?5 b" U4 \ p+ a4 n( Z OpenCmdInCurrent()
/ q0 s' {/ N( j return
* a; p- }: G- F) }; K #IfWinActive
0 q4 w. E$ _: E) D ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.+ H4 E. j8 l! v. d; S
; Note: expecting to be run when the active window is Explorer.2 G' Y0 F# O; F: d9 O3 L: }
;. |. ]+ g% _ C0 Q
OpenCmdInCurrent()% d% m# n# Z" a! s U* }0 c
{
" A, a Z; E+ I" |$ I! ] ; This is required to get the full path of the file from the address bar9 f- L( t% K$ E/ O( H1 N. D: P
WinGetText, full_path, A
1 t2 K/ F+ f, u& [. J3 o ; Split on newline (`n)
& |( C; M2 v* U8 ^ StringSplit, word_array, full_path, `n0 Y' P+ X0 o2 F6 H( F4 k3 G0 N7 i! [
; Take the first element from the array) @9 {6 C' _ U6 D# R) Z2 x7 B3 Q' q
full_path = %word_array1%
( L$ S% r+ a6 c2 y; n6 P. f# u6 w4 o ; strip to bare address3 r% d2 W4 E( P7 c6 S6 H- M
full_path := RegExReplace(full_path, “地址: “, “”)
1 C7 C' |: w& h0 x o ; Just in case – remove all carriage returns (`r)
, Z% K8 G# [; v9 m( }: Y+ `" J StringReplace, full_path, full_path, `r, , all, D, m" w1 E& V4 X, [5 q* c; A
IfInString full_path, \9 m7 A: {$ F9 u/ d& a
{5 A* S: V* n7 C. |* w" o+ F0 P
Run, cmd /K cd /D “%full_path%”% g" M! j% j P) v, j) T
}
8 s% m5 |' x$ i; q, _+ J else
1 O6 T3 S! U% K {
& {7 {, k; f& N' C. Q) D Run, cmd /K cd /D “C:\ ”
3 {( I6 s/ \$ n4 \5 Q7 b; f7 _) A5 w }: T ?' m; u! {- ]9 r. {
}4 [4 \* E4 J, X0 I
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# |1 i# ]% y) V% F 这段小代码肯能有两个你需要修改的地方7 m: o) z7 V* C& O( K. b4 w
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键2 q3 D+ ]- a- l& W6 K
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, ^6 ~0 _$ y" K
|