此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。7 P6 L9 r, ?/ t# S( b& V, g
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% f9 B0 ^0 ~* L& h _" P: ^
方式一:3 R5 Z: v! I3 ]+ q
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,) c' U% a7 ]1 y: K( h
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ `3 g" Q F. x" y HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 n: G! F5 X8 y6 g: O' G 方式二:
5 q6 ^) u& _- V) s 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
4 `- R4 _& \* Z( [3 j5 J4 } SetTitleMatchMode RegEx- b* Z7 o/ {8 i+ S1 G0 B
return
) F1 ?$ E0 k4 z! j0 g4 ?; C; p0 d ; Stuff to do when Windows Explorer is open
7 [9 I& l# L2 q7 c ;' @* Y7 ]/ s( }1 l2 }
#IfWinActive ahk_class ExploreWClass|CabinetWClass; n' C3 I( Y' B. ^
; open ‘cmd’ in the current directory
7 `/ t3 A. W9 O3 `6 a( k ;
6 I" x2 W# g. S: F #c::) y) @' A3 b4 H, N8 p$ Z# @
OpenCmdInCurrent()/ E/ v/ O, j3 i; i
return
* z; k3 D6 m# {7 }8 [4 ^ P$ H #IfWinActive8 x0 c. X0 K, k3 Z
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
" {2 b, b1 N8 B+ s' M$ n8 p ; Note: expecting to be run when the active window is Explorer.9 p/ l% ^$ n; F5 J, d% w! P* k9 p
;6 {3 q% Z8 g, A+ J8 h- k* M
OpenCmdInCurrent()
. E$ r9 j+ L/ A2 I5 Q# B { d& r& R% E! N1 A! Y
; This is required to get the full path of the file from the address bar; c* ]4 x: ]. ?8 L$ E6 |
WinGetText, full_path, A
: z' w0 i9 K1 D( I1 T2 t- b ; Split on newline (`n)
/ ^6 l3 P! y9 s' c StringSplit, word_array, full_path, `n2 D, O+ P0 L g: p
; Take the first element from the array
) l2 W- [. s0 r6 h( j" `) b full_path = %word_array1%
9 N( a( `- t5 L: `7 w' ^! } b3 N: b ; strip to bare address( J M( k* F& }
full_path := RegExReplace(full_path, “地址: “, “”)1 n/ j1 f. x; ~" I% h% m+ F$ F7 q
; Just in case – remove all carriage returns (`r)+ ~( x7 E. e$ f0 t! H8 v" g
StringReplace, full_path, full_path, `r, , all: k) [; a, R6 u% A3 @* [( U/ L
IfInString full_path, \- p9 ~# R% H* f, X% u' M- _/ a
{/ d U" l+ q9 b5 V, E) ~6 A1 q$ z# F
Run, cmd /K cd /D “%full_path%”
* W3 O- _( }0 f% Z n _ }
/ L( @( {" Q( k else; S9 N7 y! S& V* x7 V
{6 y. @3 e' i# H1 W7 i; G/ }
Run, cmd /K cd /D “C:\ ”
% t8 O) I3 w' W! L6 q6 t }9 K" z1 r- W8 O, b+ k( @: h$ A
}3 R7 s- {$ P; u
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( e" y. U" w2 U' r7 _- ~% V
这段小代码肯能有两个你需要修改的地方 I9 b1 r A: w- C8 V4 p# D
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; s+ F8 p# H+ B0 Z
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" B8 R' P; Q' K& k% b! \ |