此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- [! X% S6 h; S8 v# Y 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 g; [- V! ^! h) Y; X
方式一:" u3 X4 @: |. ^) U9 m+ B! ]7 ]6 ^; s) `
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
8 N% [8 x w) a: v7 `0 U) m& r 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
( O; n) t8 s0 m4 l2 k( h HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 q) i2 T* v$ U7 i) i) v- }
方式二:" a, x" \0 k- f; h4 M
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 R; |- [9 N+ s0 t# o
SetTitleMatchMode RegEx
0 E; V o5 Z( z. u' y return
( c! Q5 \7 v) U ; Stuff to do when Windows Explorer is open" k% m Q0 W& r
;) ?7 l' w- u5 K, M
#IfWinActive ahk_class ExploreWClass|CabinetWClass: S6 ` m5 h1 k( Q. d1 M9 z
; open ‘cmd’ in the current directory9 l. Z4 g `* ^ e' g
;1 h! X, s; J( u0 D; O
#c::
4 P8 }. k# ^$ y' F& t OpenCmdInCurrent()* z$ X g9 A' G+ q! K% N6 v6 a% o
return
9 ], s; Z# g1 Z* F' z* | #IfWinActive0 [/ F) ?; v( {0 t
; Opens the command shell ‘cmd’ in the directory browsed in Explorer., R. V9 A1 Z; P6 w) _2 w4 p" P
; Note: expecting to be run when the active window is Explorer.7 z5 b/ K$ Y) A
;8 r- w+ b- @# g! O3 O% w0 L" s
OpenCmdInCurrent()
% d9 i6 {* p! O9 ]; B6 I4 T {+ W1 b. u: a4 N# A1 y) f4 r
; This is required to get the full path of the file from the address bar
/ }( o0 A7 ?0 m WinGetText, full_path, A
! o" g" M) v! h& W5 n, t* U7 l ; Split on newline (`n)
) z! ~* E$ g* K7 t StringSplit, word_array, full_path, `n
( k/ d7 J5 E/ ]& `, M8 ` ; Take the first element from the array/ P7 O x; C. y5 x2 _) s: q9 o2 e. Y/ Y
full_path = %word_array1%( X' v2 C! M' k/ O1 z* |: l( |
; strip to bare address
' Q6 P$ j8 ~# ]! S' \3 S full_path := RegExReplace(full_path, “地址: “, “”)9 x8 z; o) }; F, c: y
; Just in case – remove all carriage returns (`r)9 Y! V( g% p+ w% x8 r" g
StringReplace, full_path, full_path, `r, , all
+ a7 j; W3 W7 ]8 g: A) R IfInString full_path, \
( a+ t1 l& Y* e! c) y {* f5 C4 m9 `2 o+ M. W0 i3 d; Z
Run, cmd /K cd /D “%full_path%”
7 Y5 c& K& Q5 q/ D& n3 _" K g }
; O0 k, l# Z# j. [2 m else, A$ L/ E7 K, a* z, `
{
3 `( n# j/ _& h0 Z8 u& \( x Run, cmd /K cd /D “C:\ ”* M+ }3 v3 |/ l6 y0 ?
}8 @/ Q" L* H2 K3 I" \- G7 d, J, F
}
# ?5 l* l; c& Y. \$ M& q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ E! @( |! y! u* h6 I 这段小代码肯能有两个你需要修改的地方* f; D0 L: l1 ?9 \& [& n, C# r. R
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键7 Y6 i! L' K% r1 Q# s Q8 v
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
' R/ o e" ~! M% _9 b7 e |