此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 |. z0 S; Y# p* J# f
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
/ C; Y& b1 f+ r- J& j 方式一:( Q2 ?: A& A# S @4 n
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, G; T3 L" B% u
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' i: [6 H. @: O8 e/ D6 R
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 S. w, w" f* e2 c2 N% q
方式二:, ]& n- @8 _- [( r! z& |
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:* g) F7 J @! b$ K% [3 J k& B
SetTitleMatchMode RegEx
( `/ [& M w6 C. A; r! a' Q1 ? return; W2 s8 s. u! _0 H
; Stuff to do when Windows Explorer is open
2 y, X5 ]1 \! v, e ;7 @. U7 U9 y& L3 G; ^
#IfWinActive ahk_class ExploreWClass|CabinetWClass
" _4 z$ H( P/ j* [4 [! V/ H ; open ‘cmd’ in the current directory& q8 m+ y3 d3 O
;
/ J4 `" T& b# n, H #c::
- l# |* n4 I% v- s% z OpenCmdInCurrent()
; s6 p8 |- }8 M/ u0 [+ W return+ `: g, V5 D1 s! l7 L
#IfWinActive
$ x( J/ @& {( a ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' p3 @! b2 j! \; D) j ; Note: expecting to be run when the active window is Explorer.
# O$ V; g9 N" V1 u! W! k- R ;
3 Z) h( r2 N: H: L+ U) G- c5 e OpenCmdInCurrent()
* h# `& }8 x4 W3 u {
) V1 m) A) k. v& k" q1 B \ ; This is required to get the full path of the file from the address bar# ?9 X2 \% n6 a$ c0 J: |$ z. [! y7 g
WinGetText, full_path, A
3 b( j2 _9 w5 e. `$ A$ Q ; Split on newline (`n)
8 D: r; d) N6 _ StringSplit, word_array, full_path, `n" N. C) u; }+ N' |; N# j/ l' r/ v
; Take the first element from the array
& ^/ Z: t" f h& O- h3 W" D full_path = %word_array1%0 u1 d$ I; p5 ~# }4 H
; strip to bare address
! P6 o0 w/ ?4 Z1 s0 R" M; _2 c full_path := RegExReplace(full_path, “地址: “, “”)
, `7 P( _( o8 I- s: y/ F ; Just in case – remove all carriage returns (`r)9 ^" u* Q% s% t2 E
StringReplace, full_path, full_path, `r, , all
1 |6 L9 F7 s3 u/ y/ b; V IfInString full_path, \
5 u8 Z, _6 t" W9 i. v. c3 R: w9 K {
/ ]* ~2 k8 {# {1 Z Run, cmd /K cd /D “%full_path%”
; D4 @5 M: U+ A6 R }3 ^& {* e1 R$ a8 D0 B
else! A; M q6 J. i' J T
{
8 t, k0 ~: F( l0 p# m' L M Run, cmd /K cd /D “C:\ ”& w6 Q+ C' Z( B$ d+ |
}
% [0 ^+ w S; c }6 j; w; h3 Z' B6 C6 x; a
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% ~7 _% `- Z9 o" a5 l2 `- r8 G
这段小代码肯能有两个你需要修改的地方9 ^! i/ r$ T! K
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
* J4 S( y; L9 p' n2 F 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; \" n a9 e7 c9 b |