此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% [2 o4 C4 ~1 | |6 X. K
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 e9 |- ?4 |3 T# |8 w- k 方式一:3 v3 i& y4 W- z. m" d) `
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,0 A7 ]3 `: N3 t; E) I! c7 P _
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和+ [; \# w* g) C8 M
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。& U$ C8 \: t8 r% Q/ Z! A
方式二:2 y( d2 R4 q, W4 N1 J9 d
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 J) C! X7 u' }+ o3 [# C" t7 j
SetTitleMatchMode RegEx8 U" ^: G* Y# L2 r+ s+ X# }
return
7 u4 v4 r( o* w. r* G) C) D ; Stuff to do when Windows Explorer is open$ F/ I% t& n2 X9 ~ V+ Q
;
7 O' x" ]6 R& H, w$ W U/ y+ r" m #IfWinActive ahk_class ExploreWClass|CabinetWClass0 l- G) D, C. o9 T0 _
; open ‘cmd’ in the current directory( A$ E i5 |4 X6 }: K
;
4 f R( }9 @0 n% b( x #c::, l7 n9 S3 H/ P7 ^$ W: s
OpenCmdInCurrent()
6 \, y# h6 E1 g! J, z return6 Y; S/ x% D% ~3 ?5 n) o1 a
#IfWinActive0 b$ P r* G5 U. a- ]
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( V9 v. M" l$ K+ y0 M m+ p ; Note: expecting to be run when the active window is Explorer.
- L' ~0 x# g+ _ ;/ a' }' M" w4 S$ D) v' N
OpenCmdInCurrent()
8 y" F8 U# ^2 a* ]# Y- f { i0 F) D" Y( G5 }
; This is required to get the full path of the file from the address bar. g% O' f r# k, _. q; C
WinGetText, full_path, A
3 R; i3 O( r$ |! |1 D0 C- U ; Split on newline (`n)7 G S2 c J$ ?5 [) G+ x/ U
StringSplit, word_array, full_path, `n u! f& f' ?3 \# P
; Take the first element from the array
5 n t* }# L) z" T7 F full_path = %word_array1%
: e$ {# r a+ ]. [ ; strip to bare address0 h, C6 m/ K3 t' T6 j! G# J; n
full_path := RegExReplace(full_path, “地址: “, “”)
3 Y& C6 {, n) E5 z ; Just in case – remove all carriage returns (`r)
5 n7 ^1 i9 A$ ?* Q StringReplace, full_path, full_path, `r, , all* I$ Y. n0 g6 S% F
IfInString full_path, \9 i; d C# \& T5 E
{
8 p3 B2 ]. i# B2 S6 Y; Q! K( ~( v, t Run, cmd /K cd /D “%full_path%”6 u' c8 P& o7 K- `" b" C1 p
}
+ |1 ^$ }) e- J, [9 ?( A else7 p9 o. J3 D( _
{* Q) s1 v1 G$ y, u" j/ h
Run, cmd /K cd /D “C:\ ”: a/ u! Y4 B0 m
}
% L$ }' U* W& e3 g( U( X: t# x& q }! w( T9 D. B. v# z7 M- M6 I
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
1 a* N8 W6 ], G: j 这段小代码肯能有两个你需要修改的地方
; s' Y7 O3 g' P 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 W) Y0 x5 X* ?6 i. G
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 p6 |1 n: _' ?& d |