此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; u( K7 f! P. k) F- ]
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 X, o7 \9 B6 O, h+ @; ]5 o 方式一:
/ n# o* S1 p( E' A! k9 R! [ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,0 e/ y+ Y3 V* N" V a
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和2 `! P4 _7 a0 R, f# e: E
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
7 G4 Y0 n( I' w, ]) B 方式二:& L8 X- P9 ~- y- \1 Z9 C
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:# s8 O( z5 x& ?6 s5 k5 F
SetTitleMatchMode RegEx
9 p4 ~- B# y7 n( h$ R return
$ j/ {* }* |/ q$ z+ E3 g/ n ; Stuff to do when Windows Explorer is open
2 k) z* _$ Z% D+ l& { ;0 R! }6 `5 s. _7 E7 X7 F7 _4 B; q
#IfWinActive ahk_class ExploreWClass|CabinetWClass) |# @) F4 y% j% k6 z4 y
; open ‘cmd’ in the current directory
! n4 i- e0 N2 p3 Y1 ? ;3 D' Z0 L+ @9 _7 G+ W8 t6 C( B* \
#c::
2 H* o' g/ ^* ^. S0 m OpenCmdInCurrent()1 S. i& P8 j! [
return
1 C1 e6 m5 c; L4 G! b& r1 | #IfWinActive6 M+ A; D) G7 f. h! H
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: ^; f! W) S' M
; Note: expecting to be run when the active window is Explorer.' r0 M* W3 z, u
;
) H- C7 y/ S% @; Y. R' e+ L0 F OpenCmdInCurrent()1 D+ v( d7 b: ]* E- @& A6 n8 t
{
% t7 Z; S i" m7 O- o W/ P ; This is required to get the full path of the file from the address bar
& y4 Q b/ Q% Y% e- U, r0 m WinGetText, full_path, A% r& j' c/ f4 ^# m8 h- U( [
; Split on newline (`n)
7 ~! ]) O V3 S0 {3 }- s" i StringSplit, word_array, full_path, `n' e' A0 O( o; u4 {, f5 F/ V
; Take the first element from the array" C4 Q5 z- z2 E: u O
full_path = %word_array1%
5 l4 ?; O6 Y, }" P# \; v ; strip to bare address" U5 K! |$ B, P7 I
full_path := RegExReplace(full_path, “地址: “, “”)) _2 H1 {! c* @: H! t+ V2 j5 T
; Just in case – remove all carriage returns (`r)9 [: j9 b8 O6 \
StringReplace, full_path, full_path, `r, , all- q1 I" Y2 y" |
IfInString full_path, \6 X; s, _4 L. A
{ z; Y* q5 S& i! k" E
Run, cmd /K cd /D “%full_path%”! D" t% X2 ^0 [6 \5 Q
}+ s- G1 ]7 Q6 _4 Y1 K' d
else! }0 F6 H) a# e' P; n" {
{% m* t1 m7 z5 B X2 T2 ~
Run, cmd /K cd /D “C:\ ”4 z4 t1 x2 q: X) n# Z
}7 y; d# i8 H$ H# h7 v5 j4 A
}
2 N5 ^$ B4 M3 v6 c f 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' w5 K8 n* e+ `2 @ _
这段小代码肯能有两个你需要修改的地方4 R& a! y- m' Q' j
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键2 y9 b4 \8 a+ y
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “' y/ \' B# \3 N" |/ F$ c# l2 R
|