此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 U9 F* g) w% l" _" O$ Q* V
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 S$ p# W* ]- A4 q. i' y9 N
方式一:
- Q t( u. f+ ]" A' d8 S; o 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,. M4 m V8 u& a
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. f4 {7 B4 m+ P/ R3 w HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。 e6 ~/ w8 @8 h7 F
方式二:) v% }; G4 f! O
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:) |" T, N4 t' U/ y3 |+ ~# y. i
SetTitleMatchMode RegEx7 U) w' E# ]7 Z& P/ C5 _0 d4 Y @9 X
return- o% X; G, \: k: Y
; Stuff to do when Windows Explorer is open- B2 Y! S" |5 I& t; z
;
9 W+ h; ]6 ?4 Z: f6 V #IfWinActive ahk_class ExploreWClass|CabinetWClass+ B S5 U* p' z2 a. C
; open ‘cmd’ in the current directory
# u9 X+ U9 Q' u) ?) k& n t ;1 t# f9 p( @" y
#c::
$ t/ x9 a1 a$ q6 y0 G7 F9 u& x OpenCmdInCurrent()& N$ U# J5 T4 S% I! q6 y
return5 \3 y7 E7 f2 B& G0 ^& S
#IfWinActive
7 _- L$ V) l, x ; Opens the command shell ‘cmd’ in the directory browsed in Explorer. z* I. b; \, G2 D' X Z2 `- l& }
; Note: expecting to be run when the active window is Explorer.
3 g6 v# @9 h6 A& b6 ` ;
' r' D1 \+ V, F2 C2 e4 t OpenCmdInCurrent()
' a& u; V5 V- P$ m( C' ~- S0 M {0 d. Y9 Z W' q6 P
; This is required to get the full path of the file from the address bar
' i5 N$ D" J2 `) m( h1 j WinGetText, full_path, A" F) A8 [/ @* g, r- X
; Split on newline (`n). K; l/ I( f( k, i% N
StringSplit, word_array, full_path, `n
; K3 a u& f. A+ y/ U0 V ; Take the first element from the array, b/ U+ c9 a! F9 H8 j: u7 c
full_path = %word_array1%$ l4 J6 C6 K7 m
; strip to bare address
2 n& O; B4 `: `7 i full_path := RegExReplace(full_path, “地址: “, “”)
! u/ N$ p2 Y, i$ o% V( c c ; Just in case – remove all carriage returns (`r)
9 u% w v4 p+ R StringReplace, full_path, full_path, `r, , all
0 b6 d0 q a9 P+ g# ?; m$ E IfInString full_path, \! }, F# ^7 Q2 C1 o
{
& _1 K& H* ^! ^! c( x D Run, cmd /K cd /D “%full_path%”+ X2 k2 T% `7 e; N
}
2 |4 Y' a2 A- u else) l4 k& M/ V6 U8 p
{6 ?7 ~2 J0 a- P: i
Run, cmd /K cd /D “C:\ ”. w8 z9 ^, R" u. R1 K8 B5 q7 ^9 J
}" ?- Z" j" ?7 r3 w0 ?+ W
}
2 O! ^* M8 u2 q; e% ]8 i1 b 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 s( F, ~9 D3 z$ h4 p# l( ~ 这段小代码肯能有两个你需要修改的地方/ K+ I2 ~7 Y6 @; B9 o4 O% `
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
: w4 ]0 { [/ U& K l& h 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
% c2 m# m3 a# R& M- { |