此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
8 V3 U, j- D) ]3 F4 {6 M( u 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 B! p' @6 Z( ~" c$ e 方式一:( j5 o" r" F7 A. ~! I$ |
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,. U3 P4 G+ ?, }
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和0 {! |; c' o3 A) `& `
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- P3 Q0 L; X3 {
方式二:
! y% D0 Q* z* m 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
4 o: S! U e8 O" [/ F2 H' { SetTitleMatchMode RegEx, I& L( e- M: z4 T
return3 H' L& c( z6 X$ }9 O9 W Q9 b
; Stuff to do when Windows Explorer is open
8 _& R0 S% Y }6 X# k e" Q5 s2 h2 b ;0 v+ x# s7 I0 \! |# E: b4 P* X
#IfWinActive ahk_class ExploreWClass|CabinetWClass
+ j0 f! x( M# I1 u6 Z ; open ‘cmd’ in the current directory/ q; s* m# \$ ]2 y2 k
;
( y& O4 L) t. J. E5 Z% D #c::0 l8 l' O+ f$ E. ?5 s! @! P- U9 R
OpenCmdInCurrent()
`& W) L- r) U1 W4 _5 O return- K( _6 q" u2 o7 Y8 H/ O; O; s' S
#IfWinActive! q! a [! e8 f/ p2 f
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.. x" K) j& s ~
; Note: expecting to be run when the active window is Explorer.
7 n6 r8 E: g( y5 ] ;
+ R7 f, |' {) @- r8 c1 ^. U$ S$ _ OpenCmdInCurrent(): s* p- v9 k* y, U4 \
{
8 a# G8 \$ p! U/ X- G8 D# T( j ; This is required to get the full path of the file from the address bar. [, Y' T+ }5 f! I
WinGetText, full_path, A' ` b. w1 w% D2 x' U9 X6 d8 J$ t
; Split on newline (`n)
5 T/ p! j m4 P! ^9 _* b8 g StringSplit, word_array, full_path, `n* J3 Y/ I: Q8 z+ H. A2 ^- W3 E9 t
; Take the first element from the array
Q) k9 z8 _0 e V5 V8 H" L full_path = %word_array1%: V$ ^8 K0 N( y( m2 V2 j- A8 l
; strip to bare address/ O( E2 U3 D4 g% ]
full_path := RegExReplace(full_path, “地址: “, “”)
( Z3 R# O2 X! H% T! e8 d ; Just in case – remove all carriage returns (`r)$ O- X" J; m( m( W; n) L
StringReplace, full_path, full_path, `r, , all1 h V1 {' F* H# \: {/ g" P2 v& X, |
IfInString full_path, \0 y2 N# p6 U/ J4 k
{
- a& x, G2 Q9 b! M- v Run, cmd /K cd /D “%full_path%”! u8 p1 i/ w, m( \, ?( q. x
}
$ y" j3 X. l: d' T+ s else: }9 f" [, g. I6 F$ }
{8 y* r$ W: ]: Q( D3 _; R( d, R" C# J1 Z# w
Run, cmd /K cd /D “C:\ ”! e5 ]- y; z5 E- |8 c! \2 ?
}0 D: [8 x8 |- ^2 |, z
}3 P* _/ P9 Q: o' W& e/ ~
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
, X' s: W1 _2 X- O1 H 这段小代码肯能有两个你需要修改的地方& Y' q& l w) k5 g# N
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 H5 q. r7 C8 b6 e+ a3 \- ~ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: R) d, T3 ] Z0 U4 B( J' a
|