此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' a& S' h& B3 O8 e. m/ K
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。/ |$ C# Y% }* o; {. a# D4 S
方式一:( Q1 ~" |3 w4 [5 x, D% N
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,& W1 u( u8 l9 [* R t/ F
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" W! _* r9 N' V2 A HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。3 N1 g2 Y, K1 R. D0 E
方式二:& u! @ t& r) d( k) ^+ N
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. n6 @ r6 G/ M6 r' Y' L
SetTitleMatchMode RegEx
# e" e6 V9 v8 q- v. a return9 d4 r+ ~" C* f6 d X
; Stuff to do when Windows Explorer is open
) T* L; |4 {7 ?0 f9 H. W" ? ;, S% `# H1 g1 F" W
#IfWinActive ahk_class ExploreWClass|CabinetWClass( o1 i, n' C8 ? k+ @7 l% V; _
; open ‘cmd’ in the current directory
, R) v2 h9 o% O1 J; j. F ;/ c: t" Z& z% O; {; `! M+ Q: D
#c::, O, V6 t8 z6 a! Y( t# [
OpenCmdInCurrent()# o5 V; e6 ^' u0 Z; g
return
" d, w' }" L4 e8 `& {, D- c! U #IfWinActive
8 G& ?- l- T( i" v8 Q; g ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.% z* b+ @" h2 k# L
; Note: expecting to be run when the active window is Explorer.
# F# {, ~! J% L' G) o2 c' E ;: [( z1 l! q( q7 e8 r& ^3 ]& k, k
OpenCmdInCurrent() o) |+ M4 d7 A: v0 x
{$ T' a# `2 v: @6 @% q
; This is required to get the full path of the file from the address bar
% x% d4 _8 G* C# W1 B) p0 y WinGetText, full_path, A
) x! g) f- S7 l; e! i) r' |' Y ; Split on newline (`n)& s3 ]' w( s' ~/ q) M' }; p! Y5 h
StringSplit, word_array, full_path, `n
- h3 B' B. [: ?% _: L ; Take the first element from the array
+ q( E$ j2 W2 G$ M full_path = %word_array1%
1 O4 G! g! b% j) d) \ ; strip to bare address- v; g/ }& ~# S3 ]! M, K
full_path := RegExReplace(full_path, “地址: “, “”)* o0 g) J* D: m& w: I
; Just in case – remove all carriage returns (`r)
& Y4 n; E3 c+ x0 Y0 ? StringReplace, full_path, full_path, `r, , all
4 P# c7 H- c$ o: I6 _ a IfInString full_path, \& l- t7 V; V4 ?- e
{* A/ q. {( e; C& ^& @2 D
Run, cmd /K cd /D “%full_path%”' p. I- S( c7 Q; _, c8 s
}9 y6 f! @( z# r Z' Q
else- M0 ]4 Y: p2 w( e1 D; u2 l
{
. S- M- H S4 I' e Run, cmd /K cd /D “C:\ ”
2 Y F$ `+ x4 [6 U2 r9 q }
! L$ {6 d g ]& q& u4 g+ x- K }
G/ p4 E: a0 G, a 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
/ K& v$ D. K# r# u5 u! B0 n. W 这段小代码肯能有两个你需要修改的地方4 p; c& [* f3 X7 w4 m7 U; U
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' N0 ~1 q1 q; n9 K3 i 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ J6 h6 T! v+ d- G& H8 w% Q6 [
|