此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 t: q! L$ |8 I8 [* y# Z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 H- p! f4 k8 l$ q4 q- l
方式一:
) j8 z/ S- w+ B- C% I 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* g6 O) m! d3 i( k7 w
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和 E- f! F: Y% x' s% v2 e) K9 `! q
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ Y# z. t. m+ O( O( n
方式二:; H; [; [2 x& O3 ^ W
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:/ D$ s2 ?$ c0 C# k* \: [4 W
SetTitleMatchMode RegEx
. E$ \/ D9 W- W2 w5 i3 H+ Q, ] W return) h, W, }& w6 c9 c' t; l
; Stuff to do when Windows Explorer is open. p8 `( ^. N3 x7 B; r5 o+ {9 K$ [1 `
;% g/ [/ ?0 {3 C8 V
#IfWinActive ahk_class ExploreWClass|CabinetWClass5 I7 i9 \5 d: x) }' W. [
; open ‘cmd’ in the current directory
/ B( d5 Z0 H# i" b3 m5 J ;) U4 |1 ^" ^9 I/ c$ a8 B
#c::# @6 A# R+ f- O5 M2 U# f! g
OpenCmdInCurrent()
) M2 `! y% _8 Q# e- @1 j& \- r return
L9 V5 E1 x; B- a- H s* b #IfWinActive0 K+ @( ]5 j; U: K
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.& x. P: p: G. l
; Note: expecting to be run when the active window is Explorer.1 {& t3 A9 X- T6 [
;
5 {0 g+ ]- h; |! O OpenCmdInCurrent()
) y! |" o( g9 E) F/ D0 y7 R e {
/ ~2 p: J( K2 S; _5 A ; This is required to get the full path of the file from the address bar
) h- G' Z/ A0 D+ }5 F8 h WinGetText, full_path, A8 m+ [8 T5 C1 m
; Split on newline (`n)2 n9 P8 q% d- T( O9 f+ n0 Y
StringSplit, word_array, full_path, `n! H) J! x4 w* r9 t, }
; Take the first element from the array
M! A* L8 q7 A$ B full_path = %word_array1%
. v# |9 W5 T/ @6 s ; strip to bare address: ^' ]3 [$ y0 B# |4 G
full_path := RegExReplace(full_path, “地址: “, “”)
$ b. w4 |: u4 _% L. A ; Just in case – remove all carriage returns (`r)3 n2 P; i2 { e
StringReplace, full_path, full_path, `r, , all+ n) w3 _& o5 c0 {& @& D$ X
IfInString full_path, \
" u" ]" B; l: x* ]+ A' T! W5 B4 A {
% K6 R' ]( D/ G7 q" @7 Q! x2 \ Run, cmd /K cd /D “%full_path%”
. U" r$ r% n* V7 V }$ \! @+ n0 p3 L, a" f
else* \7 C) S1 D" B& V: Z
{8 {" T1 O3 o k9 m% K4 R
Run, cmd /K cd /D “C:\ ”
7 m1 }+ F6 S" I: e: H* J% y }
+ G; l/ @7 n# m/ y: M+ j }
, O, v# k% V- C) M 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' p/ T8 e& R. {4 [) x
这段小代码肯能有两个你需要修改的地方
1 n8 g, A7 }% d1 s/ a 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
# a& L8 Y8 N* t2 @/ e 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! ^$ c+ {# U7 v5 h! G) [; I1 g6 c
|