此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
* i% S2 w+ S7 U; X% c 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 H* K! I5 }$ W; c3 ]
方式一:1 e8 v6 @; N2 s+ D# }# q
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
1 H9 U4 @* K) P8 J2 A 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! Y |0 l4 y/ k0 Z
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
. }+ k2 D& h. i$ K 方式二:
6 [4 H3 f' y2 ?! M, V l0 A 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
' C" ?. j) b' r1 V3 }! E SetTitleMatchMode RegEx I: b0 t& ?" @7 ~0 b6 z" l3 V
return$ f0 P" ?, `' B0 X! b8 q
; Stuff to do when Windows Explorer is open
! W0 v+ y+ n6 x1 [7 m. M ;' j3 k' a1 v2 d9 O
#IfWinActive ahk_class ExploreWClass|CabinetWClass2 V# R* G, b$ T
; open ‘cmd’ in the current directory( N5 @- f5 e0 k+ {- M0 z
;* E1 J; S, C' b2 c4 l% C, E
#c::5 G* G5 _/ H+ _+ @+ o# z# x
OpenCmdInCurrent(); {% ^" J, _1 E1 Z) ^7 w4 h9 a
return0 A* _0 H Y5 i% e6 Z* k: Q
#IfWinActive4 B, T3 ^" u* K* I; W
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' R$ ^) I+ J. m j2 x- t$ q# O ; Note: expecting to be run when the active window is Explorer.
A' H( @# @/ c% s3 U% t1 } ;+ I% ~- A$ n9 j( e7 l2 U( j
OpenCmdInCurrent()% Q7 n3 t3 k& G$ I4 h
{
$ n7 O$ L+ V* ]( j: F ; This is required to get the full path of the file from the address bar- R$ E* `& U- U4 W5 {6 N; d
WinGetText, full_path, A1 r6 k- j8 Z4 E1 M$ m
; Split on newline (`n)0 T3 S4 |" m* h$ G
StringSplit, word_array, full_path, `n! \6 Y0 F! H0 M0 ?7 v
; Take the first element from the array7 H2 S0 [1 K! y6 C6 [8 Q
full_path = %word_array1%0 ^ }7 ^3 _+ V
; strip to bare address
1 f1 v A" `: M# E: P' C full_path := RegExReplace(full_path, “地址: “, “”)
% F# I/ \1 D! d ; Just in case – remove all carriage returns (`r); {5 g9 d0 j# A! H3 B( Y) n
StringReplace, full_path, full_path, `r, , all
: t/ H8 j# i2 S2 v3 m IfInString full_path, \. e; |3 c) U+ `6 t7 [
{
" k% X# s! u! J6 h Run, cmd /K cd /D “%full_path%”
/ W1 W' r2 }4 ]# q+ w }( @& u; P. J6 D
else- J- y, l( V" N7 a' q9 i. F
{8 q' K9 D5 i- @) Q9 D8 }! S
Run, cmd /K cd /D “C:\ ”
- U8 f" J/ F" g }
- r8 T' C* {- O8 J. r. `8 K }* \. Z# _& N8 i) ^; r) t" a
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 c8 a: r4 s' M. a
这段小代码肯能有两个你需要修改的地方
6 d! f: e+ i, k/ g) j$ i 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键4 ~" [/ G& U) m p0 \2 _ d6 R
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “' O7 A( [% R" u8 r: L- K
|