此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, E; S9 o* b7 Z3 @, g- Y
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! ]4 j; d" K/ A) M; ]" g
方式一:
0 g. Q* D- I! C9 E 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 J ^ A6 ?& N 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: l) E) c: H; w' Q* r
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 r& P" U5 L3 l3 ~4 P S 方式二:
6 d; z; E9 r6 _/ I 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 |/ C( W3 u& K5 }' X! ^2 S
SetTitleMatchMode RegEx
* Y6 }% T8 N) {) G; ~# ] return& S4 c. M5 w+ F0 ^! a4 b. p
; Stuff to do when Windows Explorer is open
" i. q& V, _9 F x. L ;! l% t& S6 ^+ a$ y4 [7 \& T
#IfWinActive ahk_class ExploreWClass|CabinetWClass9 i* m; Q5 T S: p+ l
; open ‘cmd’ in the current directory0 y) w2 X+ o; V: c* z' q1 A/ t6 G
;
$ y2 b% }' h" Q/ n0 P; k7 Z #c::3 ?) i$ v3 {+ Z) s7 O! n) d
OpenCmdInCurrent()( v! V* T* o6 i( }
return6 F' m: N3 [1 j( `& G; g' j
#IfWinActive* e, D& x5 @2 z8 J+ o+ K( m
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 i* ?) V* M7 [$ P3 ^ ; Note: expecting to be run when the active window is Explorer.5 m2 ]" u: ^. f! X, p3 V4 |
;
4 ?4 y4 {: x- d, u OpenCmdInCurrent()3 K( N) q- I3 H
{/ o3 }* H1 w5 q r9 S
; This is required to get the full path of the file from the address bar
( D# P' d: ?4 C. z( u# t) @ WinGetText, full_path, A& ^; \% R$ d) F" G! [ H2 `
; Split on newline (`n)$ D8 m8 m/ t3 N8 x( X# c; V3 C# a& h
StringSplit, word_array, full_path, `n
& b4 A0 b) C' \# H% B" t- R ; Take the first element from the array" V; E1 z# T! W4 Q3 i7 b5 w
full_path = %word_array1%% E/ l2 m+ V7 i; s/ ]
; strip to bare address
' E% U; q. R2 ?' c: d full_path := RegExReplace(full_path, “地址: “, “”)
4 n9 j+ }0 O& x. L" q ; Just in case – remove all carriage returns (`r)
" X, _2 S* s& g9 P StringReplace, full_path, full_path, `r, , all
1 N m9 E$ [5 g! [ IfInString full_path, \( z1 ]& d3 S) ^& q' t" X/ @0 x
{9 u# d2 \' f# c% q8 h) Y- f9 }* R
Run, cmd /K cd /D “%full_path%”" K& k7 C& q5 G0 ^
}' e' y s" R! L3 n( a+ K7 o6 N
else
$ B' R" t3 g4 k( v5 x" u4 V- e {
& E0 f0 D6 O6 F1 m; y6 f Run, cmd /K cd /D “C:\ ”
6 Z( K# R5 D" g- U" h' Y- Y }# g/ d5 i, E6 E ~. l; Z0 n: J
}
7 O, `* r! r1 K, p' ~+ D4 O 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
; v& R( ?5 B+ x5 _" a 这段小代码肯能有两个你需要修改的地方
& N- x3 I/ l0 a9 {8 i 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( p, H; c! e3 H- y
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
( ]2 ^- A" L& e% [) | |